Created
May 31, 2018 14:31
-
-
Save danjac/ab74c9d8caefeabf26a4fd57aa6849ea to your computer and use it in GitHub Desktop.
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
# We assume 2 top level dirs for backend (Django app) and frontend (VueJS app). | |
# This is for a development setup NOT PRODUCTION-SAFE | |
# Django app uses django-configurations | |
# Environment variables are stored locally in .env file (IGNORE IN REPO) | |
#### docker-compose.yml #### | |
version: '3.4' | |
x-env: | |
&default-env | |
DATABASE_URL: postgres://postgres@db:5432/postgres | |
CACHE_URL: redis://cache:6379/0 | |
DJANGO_CELERY_BROKER_URL: redis://workers:6379/0 | |
DJANGO_SECRET_KEY: ${SECRET_KEY} | |
services: | |
db: | |
image: postgres | |
cache: | |
image: redis | |
workers: | |
image: redis | |
celery: | |
build: | |
context: ./backend | |
environment: *default-env | |
volumes: | |
- ./backend:/app | |
command: | |
bash -c "cd my_project && celery -A my_project worker -B --loglevel=info" | |
depends_on: | |
- db | |
- cache | |
- workers | |
django: | |
build: | |
context: ./backend | |
environment: *default-env | |
volumes: | |
- ./backend:/app | |
command: | |
./wait-for-it.sh db:5432 -- ./my_project/manage.py runserver 0.0.0.0:8000 | |
ports: | |
- "8000:8000" | |
volumes: | |
- ./backend:/app | |
depends_on: | |
- db | |
- celery | |
- cache | |
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 | |
#### backend/Dockerfile #### | |
FROM python:3 | |
ENV PYTHONUNBUFFERED 1 | |
RUN apt-get update && apt-get install -y postgresql-client | |
ADD . /app | |
WORKDIR /app | |
RUN pip install --upgrade pip | |
RUN pip install -r requirements.txt | |
#### frontend/Dockerfile #### | |
FROM node:latest | |
ADD . /app | |
WORKDIR /app | |
RUN npm install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment