I'm trying to do Django-project named dockerplayground with different configurations via Django-configurations. The goal is to set the configuration trough environmental variable during docker-build command. For some reason the Django-project can't find the env-variable when I start the container and uses default-value instead.
Here are my files, the Django-project is a skeleton with empty app-skaffold made with "python manage.py startapp example" command.
Dockerfile:
FROM python:3.6
RUN apt-get update && apt-get upgrade -y && apt-get autoremove && apt-get autoclean
RUN apt-get install -y \
    libffi-dev \
    libssl-dev \
    default-libmysqlclient-dev \
    libxml2-dev \
    libxslt-dev \
    libjpeg-dev \
    libfreetype6-dev \
    zlib1g-dev \
    net-tools \
    vim
RUN echo openssl version
ARG DJANGO_CONF_ARG
ENV DJANGO_CONFIGURATION=$DJANGO_CONF_ARG
RUN pip install pip --upgrade
#https://github.com/circus-tent/circus/issues/1056
RUN pip install 'tornado==4.5.3'
RUN pip install gunicorn circus
ADD requirements.txt /
RUN pip install -r requirements.txt
ADD . /
EXPOSE 8000
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh
#!/bin/bash
python manage.py makemigrations
python manage.py migrate
exec circusd circus.ini --log-level debug
exec "$@";
circus.ini
[circus]
check_delay = 5
[watcher:gunicorn]
cmd = /usr/local/bin/gunicorn
args = -b 0.0.0.0:8000 -w 2 dockerplayground.wsgi
numprocesses = 1
autostart = true
max_retry = -1
priority = 500
requirements.txt
Django==2.0.7
django-configurations
dockerplayground/wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dockerplayground.settings")
os.environ.setdefault('DJANGO_CONFIGURATION', "Dev")
from configurations.wsgi import get_wsgi_application
application = get_wsgi_application()
manage.py
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dockerplayground.settings")
    os.environ.setdefault('DJANGO_CONFIGURATION', "Dev")
    from configurations.management import execute_from_command_line
    execute_from_command_line(sys.argv)
dockerplayground/settings.py
import os
from configurations import Configuration
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
class Base(Configuration):
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = 'inbt@l4iuuc0xi7qiut_*=uh3@pi8^)nq1e6o$i2#7s8mu(3#j'
    # SECURITY WARNING: don't run with debug turned on in production!
    # DEBUG = True
    ALLOWED_HOSTS = ['*']
    # Application definition
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'example.apps.ExampleConfig'
    ]
    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]
    ROOT_URLCONF = 'dockerplayground.urls'
    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
            },
        },
    ]
    WSGI_APPLICATION = 'dockerplayground.wsgi.application'
    # Database
    # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }
    # Password validation
    # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
        },
    ]
    # Internationalization
    # https://docs.djangoproject.com/en/2.0/topics/i18n/
    LANGUAGE_CODE = 'en-us'
    TIME_ZONE = 'UTC'
    USE_I18N = True
    USE_L10N = True
    USE_TZ = True
    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/2.0/howto/static-files/
    STATIC_URL = '/static/'
class Prod(Base):
    DEBUG = False
class Dev(Base):
    DEBUG = True
Docker build command:
docker build -t dockerplayground --build-arg DJANGO_CONF_ARG=Prod . 
Docker run command:
docker run -p 8000:8000 -d  dockerplayground:latest
and then if I go to container with:
docker exec -it containerid bash
and excecute printenv I can see my environmental variable set to Prod, but localhost:8000 shows the debug-django welcoming screen. I don't know what goes wrong because Prod should not show debug-landing page at all.