Skip to content

Instantly share code, notes, and snippets.

@youngsoul
Last active September 16, 2021 18:50
Show Gist options
  • Save youngsoul/642ddcc5e84a5a30e37c24c4e67b3a51 to your computer and use it in GitHub Desktop.
Save youngsoul/642ddcc5e84a5a30e37c24c4e67b3a51 to your computer and use it in GitHub Desktop.
Django / Postgres docker compose file
version: '3.8'
# .env.docker
# DATABASE_URL=postgres://postgres:postgres@db/mydb
# POSTGRES_USER=postgres
# POSTGRES_PASSWORD=postgres
# POSTGRES_DB=mydb
services:
web:
container_name: 'django-web'
build: .
# command: python /code/manage.py runserver 0.0.0.0:8000
command: gunicorn config.wsgi -b 0.0.0.0:8000
volumes:
- .:/code
ports:
- 8000:8000
depends_on:
- db
environment:
- "ENV_PATH=.env.docker"
db:
image: postgres:13.4
container_name: 'django-db'
labels:
application: 'postgres-db'
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.docker
ports:
- "5432:5432"
expose:
- "5432"
volumes:
postgres_data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment