- Yes, I can see my secrets.
- When I deploy with my .env file the deploy and app works fine
- If I deploy without my .env file, it fails.
Reading the errors again, it seems that the docker build was already finished and it broke in the next step of deploy. Specifically in the RUN python manage.py collectstatic --noinput
step.
See the full console log:
Platform: nomad
✓ Configuration is valid
--> Verified app config
==> Building image
Remote builder fly-builder-holy-rain-5761 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 7.7s (0/1)
[+] Building 5.6s (10/10) FINISHED
=> [internal] load remote build context 0.0s
=> copy /context / 1.1s
=> [internal] load metadata for docker.io/library/python:3.10-slim-buster 1.5s
=> [1/7] FROM docker.io/library/python:3.10-slim-buster@sha256:7d6283c08f546bb7f97f8660b272dbab02e1e9bffca4fa9bc96720b0efd29d8e 0.0s
=> CACHED [2/7] RUN mkdir -p /code 0.0s
=> CACHED [3/7] WORKDIR /code 0.0s
=> CACHED [4/7] COPY requirements.txt /tmp/requirements.txt 0.0s
=> CACHED [5/7] RUN set -ex && pip install --upgrade pip && pip install -r /tmp/requirements.txt && rm -rf /root/.cache/ 0.0s
=> [6/7] COPY . /code/ 0.9s
=> ERROR [7/7] RUN python manage.py collectstatic --noinput 1.2s
------
> [7/7] RUN python manage.py collectstatic --noinput:
#10 1.166 Traceback (most recent call last):
#10 1.166 File "/code/manage.py", line 22, in <module>
#10 1.166 main()
#10 1.166 File "/code/manage.py", line 18, in main
#10 1.166 execute_from_command_line(sys.argv)
#10 1.166 File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
#10 1.167 utility.execute()
#10 1.167 File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 386, in execute
#10 1.167 settings.INSTALLED_APPS
#10 1.167 File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__
#10 1.168 self._setup(name)
#10 1.168 File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup
#10 1.168 self._wrapped = Settings(settings_module)
#10 1.168 File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__
#10 1.168 mod = importlib.import_module(self.SETTINGS_MODULE)
#10 1.168 File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
#10 1.168 return _bootstrap._gcd_import(name[level:], package, level)
#10 1.168 File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#10 1.168 File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#10 1.168 File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
#10 1.168 File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
#10 1.168 File "<frozen importlib._bootstrap_external>", line 883, in exec_module
#10 1.169 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
#10 1.169 File "/code/dpj/settings.py", line 25, in <module>
#10 1.169 SECRET_KEY = config('SECRET_KEY')
#10 1.169 File "/usr/local/lib/python3.10/site-packages/decouple.py", line 248, in __call__
#10 1.169 return self.config(*args, **kwargs)
#10 1.169 File "/usr/local/lib/python3.10/site-packages/decouple.py", line 107, in __call__
#10 1.169 return self.get(*args, **kwargs)
#10 1.169 File "/usr/local/lib/python3.10/site-packages/decouple.py", line 92, in get
#10 1.170 raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
#10 1.170 decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c python manage.py collectstatic --noinput]: exit code: 1
Not sure when the secrets are loaded in the env var.