I've been using the cookiecutter docker setup for local development which has been working wonderfully. I'm now ready to build and deploy a production version of my application.
I've followed the instructions here and here.
It all seems pretty straight-forward, however when I run the build command:
$ docker-compose -f production.yml build
I get a RuntimeError: maximum recursion depth exceeded
Traceback (most recent call last):
File "bin/docker-compose", line 6, in <module>
File "compose/cli/main.py", line 71, in main
File "compose/cli/main.py", line 121, in perform_command
File "compose/cli/command.py", line 40, in project_from_options
File "compose/cli/command.py", line 110, in get_project
File "compose/config/config.py", line 377, in load
File "compose/config/config.py", line 508, in process_config_file
File "compose/config/config.py", line 499, in
interpolate_config_section
File "compose/config/interpolation.py", line 44, in
interpolate_environment_variables
File "compose/config/interpolation.py", line 44, in <genexpr>
File "compose/config/interpolation.py", line 39, in process_item
File "compose/config/interpolation.py", line 39, in <genexpr>
File "compose/config/interpolation.py", line 54, in interpolate_value
...
...
RuntimeError: maximum recursion depth exceeded
Failed to execute script docker-compose
I'm at a loss of what might be causing this. The main difference between my local and production setup are the production.yml and .django env settings. See below. Ideas? Thanks!
production.yml
version: '2'
volumes:
postgres_data: {}
postgres_backup: {}
caddy: {}
services: &django
django:
build:
context: .
dockerfile: ./compose/production/django/Dockerfile
depends_on:
- postgres
- redis
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
- ./.envs/.production/.celery
command: /gunicorn.sh
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_backup:/backups
env_file:
- ./.envs/.production/.postgres
caddy:
build:
context: .
dockerfile: ./compose/production/caddy/Dockerfile
depends_on:
- django
volumes:
- caddy:/root/.caddy
env_file:
- ./.envs/.production/.caddy
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:443:443"
redis:
image: redis:3.0
celeryworker:
<<: *django
depends_on:
- redis
- postgres
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
- ./.envs/.production/.celery
ports: []
command: /start-celeryworker.sh
celerybeat:
<<: *django
depends_on:
- redis
- postgres
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
- ./.envs/.production/.celery
ports: []
command: /start-celerybeat.sh
.django
# General
# ------------------------------------------------------------------------------
# DJANGO_READ_DOT_ENV_FILE=True
DJANGO_SETTINGS_MODULE=config.settings.production
DJANGO_SECRET_KEY=auto generated long key
DJANGO_ADMIN_URL=auto generated admin url
DJANGO_ALLOWED_HOSTS=my deploy ip
# Security
# ------------------------------------------------------------------------------
# TIP: better off using DNS, however, redirect is OK too
DJANGO_SECURE_SSL_REDIRECT=False
# Email
# ------------------------------------------------------------------------------
MAILGUN_API_KEY=
DJANGO_SERVER_EMAIL=
MAILGUN_DOMAIN=
# AWS
# ------------------------------------------------------------------------------
DJANGO_AWS_ACCESS_KEY_ID=
DJANGO_AWS_SECRET_ACCESS_KEY=
DJANGO_AWS_STORAGE_BUCKET_NAME=
# django-allauth
# ------------------------------------------------------------------------------
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True
# Gunicorn
# ------------------------------------------------------------------------------
WEB_CONCURRENCY=4
# Sentry
# ------------------------------------------------------------------------------
DJANGO_SENTRY_DSN=
It looks like you ran into an old bug.
Does any of your auto-generated long string start with $
? If that's the case, it's causing django-environ to try to interpolate the value and crashing. Try re-generating these, and it should fix it.