Skip to content

Instantly share code, notes, and snippets.

@danjac
Created May 12, 2018 11:22
Show Gist options
  • Save danjac/a2ba8f1a37f5bb53b42a2c3ff5d587db to your computer and use it in GitHub Desktop.
Save danjac/a2ba8f1a37f5bb53b42a2c3ff5d587db to your computer and use it in GitHub Desktop.
docker-compose for typical Django+VueJS+PostgreSQL project
version: '2'
services:
db:
image: postgres
redis:
image: redis
api:
build:
context: ./backend
environment:
- DATABASE_URL=postgres://postgres@db:5432/postgres
- CACHE_URL=redis://redis:6379/0
- DJANGO_CELERY_BROKER_URL=redis://redis:6379/1
- DJANGO_SECRET_KEY=${SECRET_KEY}
volumes:
- ./backend:/app
celery:
extends:
service: api
command:
bash -c "cd project_name && celery -A project_name worker -B --loglevel=info"
depends_on:
- db
- redis
django:
extends:
service: api
command:
./wait-for-it.sh db:5432 -- ./project_name/manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- ./backend:/app
depends_on:
- db
- celery
vue:
build:
context: ./frontend
environment:
- HOST=0.0.0.0
- PORT=8080
command:
bash -c "npm install && npm run dev"
volumes:
- ./frontend:/app
ports:
- "8080:8080"
depends_on:
- django
@danjac
Copy link
Author

danjac commented May 12, 2018

@danjac
Copy link
Author

danjac commented May 12, 2018

Project structure something like:

frontend
    package.json
    src
    .....
backend
    Dockerfile
    requirements.txt
    project_name
        project_name
        django_app_1
        django_app_2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment