Django cookiecutter docker build失败:超出了最大递归深度

时间:2018-04-07 18:51:39

标签: django docker docker-compose cookiecutter-django

我一直在使用cookiecutter docker设置进行本地开发,这种设置一直非常有效。我现在准备构建和部署我的应用程序的生产版本。

我已按照说明herehere

这一切看起来都非常简单,但是当我运行构建命令时:

$ docker-compose -f production.yml build

我收到RuntimeError:超出最大递归深度

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

我不知道可能导致这种情况的原因。我的本地设置和生产设置之间的主要区别是production.yml和.django env设置。见下文。想法?谢谢!

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=

1 个答案:

答案 0 :(得分:1)

看起来你遇到了an old bug

您的任何自动生成的长字符串都以$开头吗?如果是这种情况,则会导致django-environ尝试插值并崩溃。尝试重新生成这些,它应该修复它。