Problem deploying Dockerised Django app in Heroku and Fly

38 Views Asked by At

I've successfully deployed my Django app with Fly.io.

But ever since I followed William Vincent's 'Django for Professionals' by trying to Dockerise my project, I have had no luck with updating my production server. In fact, I cannot deploy at all anymore.

I ran heroku logs --tail and this is what I got.

May you please offer any explanation as to why my 'release command' is failing?

 heroku logs --tail
 »   Warning: heroku update available from 7.53.0 to 8.6.0.
2023-10-23T12:37:29.030037+00:00 app[api]: Initial release by user 
2023-10-23T12:37:29.030037+00:00 app[api]: Release v1 created by user 
2023-10-23T12:37:29.160630+00:00 app[api]: Enable Logplex by user 
2023-10-23T12:37:29.160630+00:00 app[api]: Release v2 created by user 
2023-10-23T12:39:34.797658+00:00 app[api]: Stack changed from heroku-22 to container by user 
2023-10-23T12:39:34.813238+00:00 app[api]: Upgrade stack to container by user 
2023-10-23T12:39:34.813238+00:00 app[api]: Release v3 created by user 
2023-10-23T12:49:12.780220+00:00 app[api]: Attach DATABASE (@ref:postgresql-clean-38410) by user 
2023-10-23T12:49:12.780220+00:00 app[api]: Running release v4 commands by user 
2023-10-23T12:49:12.794484+00:00 app[api]: Release v5 created by user 
2023-10-23T12:49:12.794484+00:00 app[api]: @ref:postgresql-clean-38410 completed provisioning, setting DATABASE_URL. by user      
2023-10-23T12:53:19.000000+00:00 app[api]: Build started by user 
2023-10-23T12:54:06.000000+00:00 app[api]: Build succeeded
2023-10-23T12:54:06.158579+00:00 app[api]: Deploy e59a06da by user 
2023-10-23T12:54:06.158579+00:00 app[api]: Running release v6 commands by user 
2023-10-23T12:54:06.997250+00:00 app[api]: Starting process with command `/bin/sh -c 'if curl $HEROKU_RELEASE_LOG_STREAM --silent --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then
2023-10-23T12:54:06.997250+00:00 app[api]: chmod u+x /tmp/log-stream
2023-10-23T12:54:06.997250+00:00 app[api]: /tmp/log-stream /bin/sh -c '"'"'/bin/sh -c python\ manage.py\ collectstatic\ --noinput'"'"'
2023-10-23T12:54:06.997250+00:00 app[api]: else
2023-10-23T12:54:06.997250+00:00 app[api]: /bin/sh -c python\ manage.py\ collectstatic\ --noinput
2023-10-23T12:54:06.997250+00:00 app[api]: fi'` by user 
2023-10-23T12:54:11.328454+00:00 heroku[release.5730]: Starting process with command `/bin/sh -c 'if curl https://heroku-release-output.s3.amazonaws.com/log-stream?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZSXS6CXKUD5IMVTI%2F20231023%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231023T125406Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=e0098433f197dc99b7ad0c14325761eb27ab6132760bc1050c204b1fc366648b --silent --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then
2023-10-23T12:54:11.995701+00:00 heroku[release.5730]: State changed from starting to up
2023-10-23T12:54:12.372221+00:00 app[release.5730]: /bin/sh: 1: curl: not found
2023-10-23T12:54:13.021337+00:00 app[release.5730]: Traceback (most recent call last):
2023-10-23T12:54:13.021390+00:00 app[release.5730]: File "/code/manage.py", line 22, in <module>
2023-10-23T12:54:13.021537+00:00 app[release.5730]: main()
2023-10-23T12:54:13.021556+00:00 app[release.5730]: File "/code/manage.py", line 18, in main
2023-10-23T12:54:13.021640+00:00 app[release.5730]: execute_from_command_line(sys.argv)
2023-10-23T12:54:13.021671+00:00 app[release.5730]: File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
2023-10-23T12:54:13.021864+00:00 app[release.5730]: utility.execute()
2023-10-23T12:54:13.021885+00:00 app[release.5730]: File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 382, in execute
2023-10-23T12:54:13.022035+00:00 app[release.5730]: settings.INSTALLED_APPS
2023-10-23T12:54:13.022055+00:00 app[release.5730]: File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 102, in __getattr__   
2023-10-23T12:54:13.022154+00:00 app[release.5730]: self._setup(name)
2023-10-23T12:54:13.022181+00:00 app[release.5730]: File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 89, in _setup
2023-10-23T12:54:13.022272+00:00 app[release.5730]: self._wrapped = Settings(settings_module)
2023-10-23T12:54:13.022292+00:00 app[release.5730]: File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 217, in __init__      
2023-10-23T12:54:13.022405+00:00 app[release.5730]: mod = importlib.import_module(self.SETTINGS_MODULE)
2023-10-23T12:54:13.022425+00:00 app[release.5730]: File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
2023-10-23T12:54:13.022527+00:00 app[release.5730]: return _bootstrap._gcd_import(name[level:], package, level)
2023-10-23T12:54:13.022546+00:00 app[release.5730]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2023-10-23T12:54:13.022648+00:00 app[release.5730]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2023-10-23T12:54:13.022697+00:00 app[release.5730]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2023-10-23T12:54:13.022745+00:00 app[release.5730]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2023-10-23T12:54:13.022792+00:00 app[release.5730]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2023-10-23T12:54:13.022872+00:00 app[release.5730]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2023-10-23T12:54:13.022921+00:00 app[release.5730]: File "/code/django_project/settings.py", line 27, in <module>
2023-10-23T12:54:13.023020+00:00 app[release.5730]: SECRET_KEY = env.str("SECRET_KEY")
2023-10-23T12:54:13.023039+00:00 app[release.5730]: File "/usr/local/lib/python3.10/site-packages/environs/__init__.py", line 116, in method
2023-10-23T12:54:13.023141+00:00 app[release.5730]: raise EnvError('Environment variable "{}" not set'.format(proxied_key or parsed_key))
2023-10-23T12:54:13.023230+00:00 app[release.5730]: environs.EnvError: Environment variable "SECRET_KEY" not set
2023-10-23T12:54:13.149766+00:00 heroku[release.5730]: Process exited with status 1
2023-10-23T12:54:13.174743+00:00 heroku[release.5730]: State changed from up to complete
2023-10-23T12:54:13.840732+00:00 app[api]: Release v6 command failed by user 
2023-10-23T12:54:46.472963+00:00 app[api]: Starting process with command `manage.py migrate`

If you need to see any of my files, please advise which ones. I've only taken 2 apps into production but never through Docker.

Thank you

0

There are 0 best solutions below