2 years ago
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
>
> SECRETKEY = env("DJANGOSECRETKEY") > > ^^^^^^^^^^^^^^^^^^^^^^^^ > > File "/usr/local/lib/python3.11/site-packages/environ/environ.py", line 199, in call > > return self.getvalue(
>
> ^^^^^^^^^^^^^^^
>
> File "/usr/local/lib/python3.11/site-packages/environ/environ.py", line 392, in getvalue > > raise ImproperlyConfigured(errormsg) from exc
>
> django.core.exceptions.ImproperlyConfigured: Set the DJANGOSECRETKEY environment variable
I already put the variables in the project
16 Replies
2 years ago
please attach the dockerfile as a file
2 years ago
you have your environment variable named incorrectly
2 years ago
where is this env function defined?
2 years ago
im sorry im not sure how that answered the question?
2 years ago
either way, please see this docs section -
2 years ago
no problem!



