diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..df7e6fd --- /dev/null +++ b/docker/Dockerfile @@ -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"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..2c5619c --- /dev/null +++ b/docker/docker-compose.yml @@ -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 ' + postgres_data: + node_modules: + npm: diff --git a/docker/docker-initdb/create-db.sh b/docker/docker-initdb/create-db.sh new file mode 100644 index 0000000..13367fd --- /dev/null +++ b/docker/docker-initdb/create-db.sh @@ -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