Django failed in build. Not found in env

Hi im using dockerfile to deploy my app. My Dockerfile
Use an official Python runtime as a parent image FROM python:3.11.9 Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 Set work directory WORKDIR /usr/src/app install system dependencies RUN apt-get update && apt-get upgrade -y && apt-get install -y netcat-openbsd gcc && apt-get clean Copy file COPY . /usr/src/app/ RUN pip install -r requirements/production.txt Collect static files and migrate RUN python manage.py collectstatic --noinput --settings=config.settings.production RUN python manage.py migrate --settings=config.settings.production Run the application CMD ["gunicorn", "--workers=3", "config.wsgi"]
It failed here
File "/usr/src/app/config/settings/production.py", line 14, in <module> SECRET_KEY = env("DJANGO_SECRET_KEY") ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/environ/environ.py", line 199, in call return self.get_value( ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/environ/environ.py", line 392, in get_value raise ImproperlyConfigured(error_msg) from exc django.core.exceptions.ImproperlyConfigured: Set the DJANGO_SECRET_KEY environment variable
I already put the variables in the project
No description
16 Replies
Percy
Percy5mo ago
Project ID: 3995ec84-e5e8-447a-bc3d-a110c9b3e381
Brody
Brody5mo ago
please attach the dockerfile as a file
bluellama
bluellamaOP5mo ago
3995ec84-e5e8-447a-bc3d-a110c9b3e381
Brody
Brody5mo ago
you have your environment variable named incorrectly
bluellama
bluellamaOP5mo ago
Sorry i think on the above i paste the error message wrongly
bluellama
bluellamaOP5mo ago
No description
bluellama
bluellamaOP5mo ago
No description
bluellama
bluellamaOP5mo ago
No description
Brody
Brody5mo ago
where is this env function defined?
bluellama
bluellamaOP5mo ago
in Dockerfile
No description
bluellama
bluellamaOP5mo ago
in my django settings
Brody
Brody5mo ago
im sorry im not sure how that answered the question?
Solution
Brody
Brody5mo ago
bluellama
bluellamaOP5mo ago
okay i try follow this one first Thanks. This one works.
Brody
Brody5mo ago
no problem!
Want results from more Discord servers?
Add your server