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
Percy3mo ago
Project ID: 3995ec84-e5e8-447a-bc3d-a110c9b3e381
Brody
Brody3mo ago
please attach the dockerfile as a file
bluellama
bluellama3mo ago
3995ec84-e5e8-447a-bc3d-a110c9b3e381
Brody
Brody3mo ago
you have your environment variable named incorrectly
bluellama
bluellama3mo ago
Sorry i think on the above i paste the error message wrongly
bluellama
bluellama3mo ago
No description
bluellama
bluellama3mo ago
No description
bluellama
bluellama3mo ago
No description
Brody
Brody3mo ago
where is this env function defined?
bluellama
bluellama3mo ago
in Dockerfile
No description
bluellama
bluellama3mo ago
in my django settings
Brody
Brody3mo ago
im sorry im not sure how that answered the question?
Solution
Brody
Brody3mo ago
bluellama
bluellama3mo ago
okay i try follow this one first Thanks. This one works.
Brody
Brody3mo ago
no problem!
Want results from more Discord servers?
Add your server