【问题标题】:Django cookiecutter docker build failing: maximum recursion depth exceededDjango cookiecutter docker build 失败:超出最大递归深度
【发布时间】:2018-04-07 18:51:39
【问题描述】:

我一直在使用 cookiecutter docker setup 进行本地开发,效果很好。我现在已准备好构建和部署我的应用程序的生产版本。

我已按照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 环境设置。见下文。想法?谢谢!

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=

【问题讨论】:

    标签: django docker docker-compose cookiecutter-django


    【解决方案1】:

    您好像遇到了an old bug

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

    【讨论】:

    • @phil-butcher 我的回答解决了你的问题吗?如果是这样,你介意接受吗?谢谢
    猜你喜欢
    • 2017-08-09
    • 2011-03-31
    • 2013-02-20
    • 2013-12-01
    • 2011-09-19
    • 2019-01-18
    • 2013-03-03
    • 2017-03-24
    相关资源
    最近更新 更多