diff --git a/.gitignore b/.gitignore index 424b2f0..5c544b1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ # production **/build **/npm-debug.log* + +# Persistence Directory for Docker +**/persist diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44afc5b..e69de29 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +0,0 @@ -I will not be accepting PR's on this repository. Feel free to fork and maintain your own version. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3f939c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:lts-alpine +RUN adduser jira-clone --gecos GECOS --shell /bin/bash --disabled-password --home /app +COPY . /app +WORKDIR /app +RUN npm run install-dependencies && \ + cp -v /app/docker/entrypoint.sh /usr/bin/entrypoint +ENTRYPOINT ["entrypoint"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5732a70 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,57 @@ +version: "3.4" + +services: + db: + image: postgres:9.6-alpine + restart: always + environment: + - POSTGRES_USER=jira-clone + - POSTGRES_PASSWORD=jira-clone + - POSTGRES_DB=jira-clone + networks: + - default + volumes: + - ./persist/db/git:/var/lib/postgresql/data + + api: + build: . + restart: always + environment: + - NODE_ENV=development + - DB_HOST=db + - DB_PORT=5432 + - DB_USERNAME=jira-clone + - DB_PASSWORD=jira-clone + - DB_DATABASE=jira-clone + ## Please change this string to something unique. + - JWT_SECRET=development12345 + command: ["api"] + depends_on: + - db + networks: + - default + + client: + build: . + restart: always + environment: + ports: + - 8080:8080 + networks: + - default + environment: + - RUN_MODE=api + - NODE_ENV=development + - DB_HOST=localhost + - DB_PORT=5432 + - DB_USERNAME=jira-clone + - DB_PASSWORD=jira-clone + - DB_DATABASE=jira-clone + ## Please change this string to something unique. + - JWT_SECRET=development12345 + depends_on: + - api + command: ["client"] + +networks: + default: diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..be1a608 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +case $1 in + api ) + cd /app/api/ && npm start + ;; + client ) + cd /app/client && npm start + ;; + * ) + echo "The only two supported run modes are client and api, giving you a shell instead." + /bin/sh + ;; +esac