Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker for local dev #99

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM norionomura/swift:421

RUN apt-get update
RUN apt-get install -y postgresql libpq-dev cmake

WORKDIR /app

# cmark
RUN git clone https://github.com/commonmark/cmark
RUN make -C cmark INSTALL_PREFIX=/usr/local
RUN make -C cmark install

# javascript deps

RUN apt-get install --yes curl nodejs npm

RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

# COPY package.json package-lock.json ./
# RUN npm install

# COPY assets ./assets
# COPY Package.swift LinuxMain.swift ./
# RUN swift package update

# COPY Sources ./Sources
# COPY Tests ./Tests

# RUN swift test && swift build --configuration release

EXPOSE 8765

# CMD [".build/release/swifttalk-server"]
57 changes: 57 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: '3.7'

# create services
services:
postgres_db:
image: postgres:11-alpine
restart: always
ports:
- 8760:5432
volumes:
- ./docker-initdb/create-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: 'secret?wiftT4lk'

swift_backend:
image: swifttalk-dev
command: bash -c "npm install && swift package update && swift test && swift build --configuration release && .build/x86_64-unknown-linux/release/swifttalk-server"
working_dir: /app
# restart: on-failure
restart: "no"
ports:
- 8765:8765
volumes:
- ../package.json:/app/package.json
- ../package-lock.json:/app/package-lock.json
- ../Package.swift:/app/Package.swift
- ../LinuxMain.swift:/app/LinuxMain.swift
- ../assets:/app/assets
- ../Sources:/app/Sources
- ../Tests:/app/Tests
- node_modules:/app/node_modules
- npm:/root/.npm
environment:
# RDS_HOSTNAME: "$(ifconfig en0 | awk '/inet /{print $2}')"
BASE_URL: ""
GITHUB_CLIENT_ID: ""
GITHUB_CLIENT_SECRET: ""
GITHUB_ACCESS_TOKEN: ""
RECURLY_SUBDOMAIN: ""
RECURLY_PUBLIC_KEY: ""
RECURLY_API_KEY: ""
CIRCLE_API_KEY: ""
MAILCHIMP_API_KEY: ""
MAILCHIMP_LIST_ID: ""
VIMEO_ACCESS_TOKEN: ""
SENDGRID_API_KEY: ""

# create named volumes for reuse over different services
# and as a caching mechanism for node_modules and npm
volumes:
# when postgres password is changed here
# remove of this volume has to be done
# see 'docker volume rm <db_postgres_data>'
postgres_data:
node_modules:
npm:
6 changes: 6 additions & 0 deletions docker/docker-initdb/create-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE DATABASE swifttalk_dev;
EOSQL