Created
January 30, 2018 13:13
-
-
Save ops-gaurav/3b9abeec12b046ccd89507f44fa9327d to your computer and use it in GitHub Desktop.
DockerCompose Nodejs, Express, MongoDB, Nginx, Staging/Production
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
# This is the production variant of | |
# docker deployment | |
version: '3' | |
services: | |
#built by master branch | |
<container-name>: | |
image: index.docker.io/<account>/<repo>:master | |
container_name: '<app-name>' | |
ports: | |
- 8000:3000 | |
links: | |
- database | |
depends_on: | |
- database | |
env_file: | |
- ./env-production.env | |
environment: | |
- NODE_ENV=production | |
- MONGO_HOST=database | |
- MONGO_DB=tidif | |
# application for development environment | |
# image built based upon the development branch | |
<app-name>-development: | |
image: index.docker.io/<account>/<repo>:development | |
container_name: '<app-name>-development' | |
ports: | |
- 3000:3000 | |
links: | |
- database | |
depends_on: | |
- database | |
env_file: ./env-development.env | |
environment: | |
- NODE_ENV=development | |
- MONGO_HOST=database | |
- MONGO_DB=litnite-development | |
database: | |
image: mongo | |
container_name: 'mongodb' | |
volumes: | |
- ./data/db:/data/db | |
restart: always | |
ports: | |
- "27017:27017" | |
nginx: | |
image: nginx:alpine | |
ports: | |
- "80:80" | |
volumes: | |
- ./configurations/nginx.conf:/etc/nginx/conf.d/default.conf | |
links: | |
- litnite-app-development:linite-dev | |
# adding watchtower to waxtch for newly build images | |
# mentioned above | |
watchtower: | |
image: v2tec/watchtower | |
container_name: 'watchtower' | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
- ./.docker/config.json:/config.json | |
command: --interval 10 --cleanup |
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
server { | |
listen 80; | |
listen [::]:80; | |
location /development/ { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_pass http://<app-name>-development:3000/; | |
#proxy_http_version 1.1; | |
#proxy_set_header Upgrade $http_upgrade; | |
#proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $http_host; | |
proxy_cache_bypass $http_upgrade | |
proxy_redirect off; | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
#try_files $uri $uri/ =404; | |
} | |
# production configuration | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_pass http://<app-name>:8000/; | |
#proxy_http_version 1.1; | |
#proxy_set_header Upgrade $http_upgrade; | |
#proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $http_host; | |
proxy_cache_bypass $http_upgrade | |
proxy_redirect off; | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
#try_files $uri $uri/ =404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment