Last active
July 15, 2024 17:31
docker-compose for Django with Celery,Redis,Nginx and PostgreSQL
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
services: | |
# Creates a new service called db with Postgres database | |
db: | |
image: postgres:13 | |
container_name: postgres | |
restart: always | |
volumes: | |
- booth_base:/var/lib/postgresql/data | |
env_file: | |
- .env | |
environment: | |
POSTGRES_DB: ${DB_NAME} | |
POSTGRES_USER: ${DB_USER} | |
POSTGRES_PASSWORD: ${DB_PASSWORD} | |
healthcheck: | |
test: | |
[ | |
"CMD-SHELL", | |
"pg_isready -U ${DB_USER} -d ${DB_NAME}" | |
] | |
interval: 4s | |
timeout: 7s | |
retries: 40 | |
# Creates a new service called redis with Redis cache | |
redis: | |
image: redis:latest | |
container_name: redis | |
restart: always | |
#Creates a new service called celery with Celery worker | |
celery: | |
container_name: celery | |
restart: always | |
build: . | |
command: sh -c "celery -A app worker -l info" | |
env_file: | |
- .env | |
environment: | |
DB_HOST: ${DB_HOST} | |
DB_NAME: ${DB_NAME} | |
DB_USER: ${DB_USER} | |
DB_PASS: ${DB_PASSWORD} | |
volumes: | |
- ./src:/app | |
depends_on: | |
- redis | |
- web | |
- db | |
# Creates a new service called booth with Django application | |
web: | |
image: web | |
container_name: booth | |
command: sh -c "gunicorn app.wsgi:application --bind 0.0.0.0:5656 --reload " | |
restart: unless-stopped | |
env_file: | |
- .env | |
build: | |
context: . | |
dockerfile: ./Dockerfile | |
volumes: | |
- ./src:/app | |
- ./src/static:/static | |
expose: | |
- 5656 | |
depends_on: | |
- db | |
# Creates a new service called nginx with Nginx web server | |
nginx: | |
image: nginx:latest | |
container_name: nginx | |
restart: unless-stopped | |
ports: | |
- 5656:5656 | |
volumes: | |
- ./nginx:/etc/nginx/conf.d | |
depends_on: | |
- web | |
volumes: | |
booth_base: | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment