Created
May 12, 2018 11:22
-
-
Save danjac/a2ba8f1a37f5bb53b42a2c3ff5d587db to your computer and use it in GitHub Desktop.
docker-compose for typical Django+VueJS+PostgreSQL project
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: '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 |
wait-for-it.sh here: https://github.com/vishnubob/wait-for-it
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
Uses a single Redis instance for celery + cache. This is intended for development use only.