Last active
March 26, 2018 12:06
-
-
Save ops-gaurav/143d74f396bfeb36193ef9dc00904336 to your computer and use it in GitHub Desktop.
Docker compose single docker nodejs application on different ports using nginx server. Complete docker stack
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
# This is the production variant of | |
# docker deployment for litnite | |
version: '3' | |
services: | |
#built by master branch | |
litnite-app: | |
image: index.docker.io/litnite/backend:master | |
container_name: 'litnite' | |
ports: | |
- 3001:3001 | |
# links: | |
# - database | |
# depends_on: | |
# - database | |
env_file: | |
- ./env-production.env | |
environment: | |
- NODE_ENV=production | |
- MONGO_HOST=database | |
- MONGO_DB=litnite | |
# application for development environment | |
# image built based upon the development branch | |
litnite-app-development: | |
image: index.docker.io/litnite/backend:development | |
container_name: 'litnite-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:3.4.0 | |
# container_name: 'mongodb' | |
# volumes: | |
# - ./data/db:/data/db | |
# restart: always | |
# ports: | |
# - "27017:27017" | |
nginx: | |
image: nginx:latest | |
container_name: 'nginx' | |
ports: | |
- "80:80" | |
volumes: | |
- ./configurations/nginx.conf:/etc/nginx/conf.d/default.conf | |
- ./certs:/etc/nginx/certs | |
depends_on: | |
- litnite-app | |
- litnite-app-development | |
- litnite-webapp | |
# - litnite-webapp-development | |
# configuring the litnite webapp | |
# litnite-webapp-development: | |
# image: index.docker.io/litnite/webapp:development | |
# container_name: 'lintite-webapp-development' | |
# ports: | |
# - 8000:8000 | |
# environment: | |
# - NODE_ENV=development | |
# production build of the web app | |
litnite-webapp: | |
image: index.docker.io/litnite/webapp:master | |
container_name: 'litnite-webapp' | |
ports: | |
- 8001:8001 | |
environment: | |
- NODE_ENV=production | |
# 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 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
server { | |
listen 80; | |
listen [::]:80; | |
server_name mylitnite.com www.mylitnite.com; | |
listen 443 ssl; | |
client_max_body_size 20M; | |
#RSA certificate | |
ssl_certificate /etc/nginx/certs/certificate.crt; | |
ssl_certificate_key /etc/nginx/certs/private.key; | |
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://litnite-app-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 /production/ { | |
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://litnite-app:3001/; | |
#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; | |
} | |
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://litnite-webapp:8001/; | |
#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; | |
} | |
# location /dev/ { | |
# 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://litnite-webapp-development: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