Last active
August 23, 2020 15:21
-
-
Save Santiago-j-s/6b26e9a512f18b3f1127f1e82d5dd51e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
mongo: | |
image: mongo | |
restart: always | |
ports: | |
- '5100:27017' | |
volumes: | |
- ./mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro | |
- mongodb:/data/db | |
environment: | |
MONGO_INITDB_DATABASE: challenge | |
MONGO_INITDB_ROOT_USERNAME: root | |
MONGO_INITDB_ROOT_PASSWORD: SiybNkozPC4x7iHaNVFH | |
server: | |
env_file: | |
- '.env' | |
build: | |
context: ./ | |
volumes: | |
- .:/home/node | |
- /home/node/node_modules | |
- /home/node/imgs | |
restart: always | |
depends_on: | |
- mongo | |
ports: | |
- '6100:8080' | |
development: | |
image: node:12-alpine | |
env_file: | |
- '.env' | |
volumes: | |
- .:/app | |
- nodemodules:/app/nodemodules | |
- imgs:/app/imgs | |
working_dir: /app | |
command: npm run dev | |
depends_on: | |
- mongo | |
ports: | |
- '7100:3000' | |
environment: | |
- NODE_ENV=development | |
- PORT=3000 | |
volumes: | |
mongodb: | |
nodemodules: | |
imgs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PRODUCTION DOCKERFILE | |
# --------------------- | |
# Sourced from: https://github.com/Saluki/nestjs-template/blob/master/Dockerfile | |
# | |
# This Dockerfile allows to build a Docker image of the Express application | |
# and based on a NodeJS 12 image. The multi-stage mechanism allows to build | |
# the application in a "builder" stage and then create a lightweight production | |
# image containing the required dependencies and the JS build files. | |
# | |
# Dockerfile best practices | |
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ | |
# Dockerized NodeJS best practices | |
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md | |
# https://www.bretfisher.com/node-docker-good-defaults/ | |
# http://goldbergyoni.com/checklist-best-practice-of-node-js-in-production/ | |
FROM node:12-alpine as builder | |
ENV NODE_ENV build | |
USER node | |
WORKDIR /home/node | |
COPY . /home/node | |
RUN npm ci \ | |
&& npm run build | |
# --- | |
FROM node:12-alpine | |
ENV NODE_ENV production | |
USER node | |
WORKDIR /home/node | |
COPY --from=builder /home/node/package*.json /home/node/ | |
COPY --from=builder /home/node/dist/ /home/node/dist/ | |
RUN npm ci | |
CMD ["node", "dist/server.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment