Created
March 3, 2022 14:28
-
-
Save un-versed/455980d5c227b2ea7fd40be48fefea00 to your computer and use it in GitHub Desktop.
Node.js | Dockerfile + docker-compose.yml
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' | |
services: | |
node-api: | |
build: . | |
image: node-api | |
restart: always | |
depends_on: | |
- mongodb | |
ports: | |
- 3000:3000 | |
environment: | |
MONGODB_URI: mongodb://mongodb:27017/node-api | |
networks: | |
- app-network | |
mongodb: | |
image: mongo | |
ports: | |
- 27017:27017 | |
volumes: | |
- mongodb:/data/db | |
restart: always | |
networks: | |
- app-network | |
volumes: | |
mongodb: | |
networks: | |
app-network: | |
driver: bridge |
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
FROM node:16-alpine as builder | |
WORKDIR /home/node/app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
ENV PORT=3000 | |
ENV NODE_ENV=production | |
ENV SECRET=randomHashSecret | |
RUN npm ci --production | |
EXPOSE 3000 | |
CMD [ "npm", "start" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment