From 15b7d2cda32d3f818bc56284f40e26768d7632ba Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Tue, 17 Nov 2020 17:30:13 +0100 Subject: [PATCH] chore: add docker-compose support and Dockerfile for building the app image --- .gitignore | 3 +++ Dockerfile | 11 +++++++++++ docker-compose.yaml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/.gitignore b/.gitignore index a812403..ce7b1ec 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ node_modules .node_repl_history .idea + +# Storage place for local files, such as developer database etc. +local/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..10d4696 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:14 + +WORKDIR /opt/obsAPI +ADD package.json package-lock.json /opt/obsAPI/ +RUN npm ci + +ADD _helpers _middleware accounts config models public routes app.js /opt/obsAPI/ + +EXPOSE 8080 +ENV PORT=8080 +CMD ["npm", "start"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c07ecc4 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,35 @@ +version: '3' + +services: + mongo: + image: mongo + tty: true + volumes: + - ./local/mongo:/data/db + ports: + - '27017:27017' + restart: on-failure + + api: + image: obs-api + build: + context: . + dockerfile: ./Dockerfile + volumes: + - ./_helpers:/opt/obsAPI/_helpers + - ./_middleware:/opt/obsAPI/_middleware + - ./accounts:/opt/obsAPI/accounts + - ./config:/opt/obsAPI/config + - ./data:/opt/obsAPI/data + - ./models:/opt/obsAPI/models + - ./public:/opt/obsAPI/public + - ./routes:/opt/obsAPI/routes + - ./app.js:/opt/obsAPI/app.js + environment: + - PORT=3000 + - MONGODB_URL=mongodb://mongo/obsTest + links: + - mongo + ports: + - '3000:3000' + restart: on-failure