Created
March 22, 2020 22:42
-
-
Save vinicius73/1338dd2294a16274670ee1fc8f561edb to your computer and use it in GitHub Desktop.
Docker + PM2 - Node Backend APP
This file contains hidden or 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
| node_modules/ | |
| dist/ | |
| .git/ |
This file contains hidden or 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
| APP_HOST=0.0.0.0 | |
| APP_PORT=8073 | |
| APP_NAME=my-suppa-app |
This file contains hidden or 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.5' | |
| x-networks: | |
| &default-networks | |
| networks: | |
| - app-network | |
| networks: | |
| app-network: | |
| driver: bridge | |
| name: "${APP_NAME}-network" | |
| services: | |
| server: | |
| << : *default-networks | |
| environment: | |
| - NODE_ENV=development | |
| command: "yarn run dev" |
This file contains hidden or 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.5' | |
| services: | |
| server: | |
| build: | |
| context: . | |
| dockerfile: Dockerfile | |
| user: "node" | |
| restart: unless-stopped | |
| working_dir: /app | |
| environment: | |
| - NODE_ENV=production | |
| volumes: | |
| - ./:/home/node/app | |
| ports: | |
| - ${PORT}:${PORT} | |
| command: "yarn run start" |
This file contains hidden or 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:12-alpine | |
| RUN apk add --no-cache curl gnupg libstdc++ | |
| ENV NODE_ENV production | |
| ENV APP_HOST 0.0.0.0 | |
| ENV APP_PORT 8073 | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| COPY yarn.lock ./ | |
| RUN yarn install | |
| COPY . . | |
| CMD ["yarn", "start"] | |
This file contains hidden or 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
| module.exports = { | |
| apps: [{ | |
| name: 'my-suppa-app', | |
| script: './src/index.js', | |
| ignore_watch: ['node_modules', 'data', '.git', '*.log'], | |
| env: { | |
| NODE_ENV: 'development' | |
| }, | |
| env_production: { | |
| NODE_ENV: 'production' | |
| } | |
| }] | |
| } |
This file contains hidden or 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
| { | |
| "start": "pm2 start", | |
| "dev": "pm2 start --watch" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment