chore: add docker-compose support and Dockerfile for building the app image

This commit is contained in:
Paul Bienkowski 2020-11-17 17:30:13 +01:00
parent 6ff0c4fb21
commit 15b7d2cda3
3 changed files with 49 additions and 0 deletions

3
.gitignore vendored
View file

@ -35,3 +35,6 @@ node_modules
.node_repl_history .node_repl_history
.idea .idea
# Storage place for local files, such as developer database etc.
local/

11
Dockerfile Normal file
View file

@ -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"]

35
docker-compose.yaml Normal file
View file

@ -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