Introduce development-time Celery services (#1257)

* Introduce development-time Celery services

Closes #1225.

* Re-order django and postgres services in production.yml

* Switch local service extension tactics

* Fix celery services inheriting ports from the django's
This commit is contained in:
Shupeyko Nikita 2017-08-11 10:13:30 +03:00 committed by Jannis Gebauer
parent a5129ecbe4
commit 035dc4d7ab
5 changed files with 70 additions and 25 deletions

View File

@ -13,6 +13,14 @@ COPY ./compose/django/start-dev.sh /start-dev.sh
RUN sed -i 's/\r//' /start-dev.sh
RUN chmod +x /start-dev.sh
COPY ./compose/django/celery/worker/start-dev.sh /start-celeryworker-dev.sh
RUN sed -i 's/\r//' /start-celeryworker-dev.sh
RUN chmod +x /start-celeryworker-dev.sh
COPY ./compose/django/celery/beat/start-dev.sh /start-celerybeat-dev.sh
RUN sed -i 's/\r//' /start-celerybeat-dev.sh
RUN chmod +x /start-celerybeat-dev.sh
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -0,0 +1,8 @@
#!/bin/sh
set -o errexit
set -o nounset
set -o xtrace
rm -f './celerybeat.pid'
celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO

View File

@ -0,0 +1,7 @@
#!/bin/sh
set -o errexit
set -o nounset
set -o xtrace
celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO

View File

@ -5,6 +5,22 @@ volumes:
postgres_backup_dev: {}
services:
django: &django
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
depends_on:
- postgres{% if cookiecutter.use_mailhog == 'y' %}
- mailhog{% endif %}
volumes:
- .:/app
environment:
- POSTGRES_USER={{cookiecutter.project_slug}}
- USE_DOCKER=yes
ports:
- "8000:8000"
command: /start-dev.sh
postgres:
build: ./compose/postgres
volumes:
@ -12,23 +28,6 @@ services:
- postgres_backup_dev:/backups
environment:
- POSTGRES_USER={{cookiecutter.project_slug}}
django:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
command: /start-dev.sh
depends_on:
- postgres{% if cookiecutter.use_mailhog == 'y' %}
- mailhog{% endif %}
environment:
- POSTGRES_USER={{cookiecutter.project_slug}}
- USE_DOCKER=yes
volumes:
- .:/app
ports:
- "8000:8000"
{% if cookiecutter.use_pycharm == 'y' %}
pycharm:
build:
@ -41,10 +40,33 @@ services:
volumes:
- .:/app
{% endif %}
{% if cookiecutter.use_mailhog == 'y' %}
mailhog:
image: mailhog/mailhog:v1.0.0
ports:
- "8025:8025"
{% endif %}
{% if cookiecutter.use_celery == 'y' %}
redis:
image: redis:3.0
celeryworker:
# https://github.com/docker/compose/issues/3220
<<: *django
depends_on:
- redis
- postgres{% if cookiecutter.use_mailhog == 'y' %}
- mailhog{% endif %}
ports: []
command: /start-celeryworker-dev.sh
celerybeat:
# https://github.com/docker/compose/issues/3220
<<: *django
depends_on:
- redis
- postgres{% if cookiecutter.use_mailhog == 'y' %}
- mailhog{% endif %}
ports: []
command: /start-celerybeat-dev.sh
{% endif %}

View File

@ -5,13 +5,6 @@ volumes:
postgres_backup: {}
services:
postgres:
build: ./compose/postgres
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_backup:/backups
env_file: .env
django:
build:
context: .
@ -22,6 +15,13 @@ services:
command: /gunicorn.sh
env_file: .env
postgres:
build: ./compose/postgres
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_backup:/backups
env_file: .env
nginx:
build: ./compose/nginx
depends_on: