Fix CELERY_BROKER_URL overriden in entrypoint.sh

Closes #1235.
This commit is contained in:
Nikita P. Shupeyko 2018-03-08 18:10:38 +03:00
parent 5543359382
commit 03ee6c78d6
7 changed files with 41 additions and 15 deletions

View File

@ -249,6 +249,11 @@ def remove_envs_and_associated_files():
os.remove('merge_production_dotenvs_in_dotenv.py') os.remove('merge_production_dotenvs_in_dotenv.py')
def remove_celery_envs():
os.remove(os.path.join('.envs', '.local', '.celery'))
os.remove(os.path.join('.envs', '.production', '.celery'))
def main(): def main():
postgres_user = generate_postgres_user() postgres_user = generate_postgres_user()
set_flags_in_envs(postgres_user) set_flags_in_envs(postgres_user)
@ -311,6 +316,8 @@ def main():
if '{{ cookiecutter.use_celery }}'.lower() == 'n': if '{{ cookiecutter.use_celery }}'.lower() == 'n':
remove_celery_app() remove_celery_app()
if '{{ cookiecutter.use_docker }}'.lower() == 'y':
remove_celery_envs()
if '{{ cookiecutter.use_travisci }}'.lower() == 'n': if '{{ cookiecutter.use_travisci }}'.lower() == 'n':
remove_dottravisyml_file() remove_dottravisyml_file()

View File

@ -0,0 +1,3 @@
# Celery
# ------------------------------------------------------------------------------
CELERY_BROKER_URL=redis://redis:6379/0

View File

@ -0,0 +1,3 @@
# Celery
# ------------------------------------------------------------------------------
CELERY_BROKER_URL=redis://redis:6379/0

View File

@ -7,11 +7,6 @@ set -o nounset
cmd="$@" cmd="$@"
export REDIS_URL=redis://redis:6379
{%- if cookiecutter.use_celery == 'y' %}
export CELERY_BROKER_URL="${REDIS_URL}/0"
{%- endif %}
if [ -z "${POSTGRES_USER}" ]; then if [ -z "${POSTGRES_USER}" ]; then
# the official postgres image uses 'postgres' as default user if not set explictly. # the official postgres image uses 'postgres' as default user if not set explictly.
export POSTGRES_USER=postgres export POSTGRES_USER=postgres

View File

@ -11,7 +11,7 @@ services:
dockerfile: ./compose/local/django/Dockerfile dockerfile: ./compose/local/django/Dockerfile
depends_on: depends_on:
- postgres - postgres
{% if cookiecutter.use_mailhog == 'y' -%} {%- if cookiecutter.use_mailhog == 'y' %}
- mailhog - mailhog
{%- endif %} {%- endif %}
volumes: volumes:
@ -19,6 +19,9 @@ services:
env_file: env_file:
- ./.envs/.local/.django - ./.envs/.local/.django
- ./.envs/.local/.postgres - ./.envs/.local/.postgres
{%- if cookiecutter.use_celery == 'y' %}
- ./.envs/.local/.celery
{%- endif %}
ports: ports:
- "8000:8000" - "8000:8000"
command: /start.sh command: /start.sh
@ -32,12 +35,16 @@ services:
- postgres_backup_local:/backups - postgres_backup_local:/backups
env_file: env_file:
- ./.envs/.local/.postgres - ./.envs/.local/.postgres
{% if cookiecutter.use_mailhog == 'y' %} {%- if cookiecutter.use_mailhog == 'y' %}
mailhog: mailhog:
image: mailhog/mailhog:v1.0.0 image: mailhog/mailhog:v1.0.0
ports: ports:
- "8025:8025" - "8025:8025"
{% endif %}{% if cookiecutter.use_celery == 'y' %}
{%- endif %}
{%- if cookiecutter.use_celery == 'y' %}
redis: redis:
image: redis:3.0 image: redis:3.0
@ -49,6 +56,8 @@ services:
{% if cookiecutter.use_mailhog == 'y' -%} {% if cookiecutter.use_mailhog == 'y' -%}
- mailhog - mailhog
{%- endif %} {%- endif %}
env_file:
- ./.envs/.local/.celery
ports: [] ports: []
command: /start-celeryworker.sh command: /start-celeryworker.sh
@ -60,6 +69,9 @@ services:
{% if cookiecutter.use_mailhog == 'y' -%} {% if cookiecutter.use_mailhog == 'y' -%}
- mailhog - mailhog
{%- endif %} {%- endif %}
env_file:
- ./.envs/.local/.celery
ports: [] ports: []
command: /start-celerybeat.sh command: /start-celerybeat.sh
{% endif %}
{%- endif %}

View File

@ -8,6 +8,9 @@ PRODUCTION_DOTENVS_DIR_PATH = os.path.join(ROOT_DIR_PATH, '.envs', '.production'
PRODUCTION_DOTENV_FILE_PATHS = [ PRODUCTION_DOTENV_FILE_PATHS = [
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.django'), os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.django'),
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.postgres'), os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.postgres'),
{%- if cookiecutter.use_celery == 'y' %}
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.celery'),
{%- endif %}
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.caddy'), os.path.join(PRODUCTION_DOTENVS_DIR_PATH, '.caddy'),
] ]
DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, '.env') DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, '.env')

View File

@ -16,6 +16,9 @@ services:
env_file: env_file:
- ./.envs/.production/.django - ./.envs/.production/.django
- ./.envs/.production/.postgres - ./.envs/.production/.postgres
{%- if cookiecutter.use_celery == 'y' %}
- ./.envs/.production/.celery
{%- endif %}
command: /gunicorn.sh command: /gunicorn.sh
postgres: postgres:
@ -44,15 +47,15 @@ services:
redis: redis:
image: redis:3.0 image: redis:3.0
{% if cookiecutter.use_celery == 'y' %} {%- if cookiecutter.use_celery == 'y' %}
celeryworker: celeryworker:
<<: *django <<: *django
depends_on: depends_on:
- postgres - postgres
- redis - redis
env_file: env_file:
- ./.envs/.production/.django - ./.envs/.production/.celery
- ./.envs/.production/.postgres
command: /start-celeryworker.sh command: /start-celeryworker.sh
celerybeat: celerybeat:
@ -61,7 +64,7 @@ services:
- postgres - postgres
- redis - redis
env_file: env_file:
- ./.envs/.production/.django - ./.envs/.production/.celery
- ./.envs/.production/.postgres
command: /start-celerybeat.sh command: /start-celerybeat.sh
{% endif %}
{%- endif %}