Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@b4oshany
Last active March 27, 2020 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b4oshany/9401868ec4ff0593468f1fed21ff2156 to your computer and use it in GitHub Desktop.
Save b4oshany/9401868ec4ff0593468f1fed21ff2156 to your computer and use it in GitHub Desktop.
Nginx + Postgres + RabbitMQ + PgAdmin + other app
version: '3.7'
services:
# App service
app:
build: .
restart: always
container_name: app
volumes:
- ./app.ini:/app/app.ini:ro
- ./uploads:/app/uploads
- ./dumps:/app/dupms
- ./tests:/app/tests/
networks:
- app_frontend
- app_backend
- db_backend
deploy:
labels:
environment: "Staging"
# Deploy two containers for the app service
mode: replicated
replicas: 2
# The restart policy only works in Docker Compose Version 3.7
# If the service needs to restart, restart graceful to ensure that
# there's no down time and at least one container is up for the service.
restart_policy:
delay: 3m
max_attempts: 6
window: 3m
# If rollback is needed in case of failure or anything, then gracefully
# rollback each service container one after another after ensure the
# container was succesfully rollback with positive health checks.
rollback_config:
parallelism: 1
delay: 2m
monitor: 2m
order: stop-first
# Gracefully stop, update and restart each service container one after
# another, but not before ensure that the
# container was succesfully updated with positive health checks.
update_config:
parallelism: 1
delay: 2m
monitor: 2m
# Docker Compose Version 3.7 feature
order: stop-first
env_file: .env
depends_on:
- rabbitmq
expose:
- 8080
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: rabbitmq
networks:
# Set the external ip address of the container
# to a static ip to allow other applications
# that is dockerized to access RabbitMQ via the static ip address
# while allow other containers to access the RabbitMQ by using the
# service name.
app_backend:
rabbitmq_net:
ipv4_address: 172.90.239.10
ipv6_address: 2021:3101:3289::10
env_file: .env
restart: always
ports:
- 5672:5672
- 15672:15672
# Load balancer the containers for the app microservice.
nginx:
image: nginx:1.17
container_name: app_nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
ports:
- "12050:80"
networks:
- app_frontend
postgres:
image: postgres:12
env_file: .env
volumes:
- ./.docker/dbdata:/var/lib/postgresql/data
networks:
- db_backend
ports:
- "5432:5432"
pgadmin:
image: dpage/pgadmin4
env_file: .env
volumes:
- ./.docker/pgadmindata:/root/.pgadmin
ports:
- "12050:80"
depends_on:
- postgres
networks:
- db_backend
# Seeting up networks
networks:
app_frontend:
app_backend:
db_backend:
rabbitmq_net:
ipam:
driver: default
config:
- subnet: "172.90.239.0/24"
- subnet: "2020:3804:3089::/64"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment