Last active
April 6, 2022 12:27
-
-
Save marianobrc/bbd4b135601fc1d20cea8df4a2fbbcad to your computer and use it in GitHub Desktop.
A docker-compose.yml sample for a local django-postgres development environment
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
version: '3.5' | |
services: | |
db: | |
image: postgres:10 | |
restart: always | |
# Optional: Map the container port to a host port to be able to connect with a local db client | |
ports: | |
- ${DB_PORT}:${DB_PORT} | |
environment: | |
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | |
- DB_NAME=${DB_NAME} | |
- DB_USER=${DB_USER} | |
- DB_PASSWORD=${DB_PASSWORD} | |
volumes: | |
- ./db/psql-init/db.sql:/docker-entrypoint-initdb.d/db.sql | |
- postgres_data:/var/lib/postgresql/data/ | |
app: | |
build: | |
context: ../ | |
dockerfile: ./docker/app/Dockerfile | |
target: dev | |
restart: always | |
depends_on: | |
- db | |
environment: | |
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} | |
- DB_HOST=${DB_HOST} | |
- DB_PORT=${DB_PORT} | |
- DB_NAME=${DB_NAME} | |
- DB_USER=${DB_USER} | |
- DB_PASSWORD=${DB_PASSWORD} | |
volumes: | |
- ../:/home/web/code | |
ports: | |
- 8000:8000 | |
volumes: | |
postgres_data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment