Dockerisierte Django -App - "Gunicorn: Befehl nicht gefunden" auf AWS -Bereitstellung
Posted: 07 Apr 2025, 23:04
Ich habe eine dockerisierte Django -App, die in einer AWS T3A.Micro EC2 -Instanz bereitgestellt wird - Nach einigen aktuellen Updates für die Debian- und Postgresql -Bilder, die ich in der Dockerfile verwende, kann die App plötzlich nicht ausgeführt werden, wenn sie AWS aufgrund eines Problems mit Gunicorn
auftretendt. und in den Container ausführe, kann ich Gunicorn ohne Problem ausführen. Ich bin mir also nicht sicher, wie das Problem ist - Gunicorn ist in den Anforderungen enthalten. Anforderungen.
-
Abgesehen von diesen Änderungen sind diese Dateien genau gleich. in den Anforderungen.txt zur neuesten Version, aber nichts hat geholfen. Aus irgendeinem Grund ist der Befehl gunicorn in der implementierten Umgebung nicht verfügbar, aber ich verstehe nicht, warum.>
auftretendt.
Code: Select all
pyenv: gunicorn: command not found
< /code>
Dieses [url=viewtopic.php?t=20324]Problem[/url] trat zuvor nicht auf, und wenn ich einfach einen Build basierend auf dem vorherigen GIT -Commit (bevor ich diese Updates) basierend auf dem Weg zur Verfügung stelle, bereitet die App einwandfrei bereit und läuft gut. Wenn ich die App lokal über Docker -Compose up
Code: Select all
Dockerfile
Code: Select all
FROM andrejreznik/python-gdal:py3.11.10-gdal3.6.2
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install postgresql-15 postgresql-server-dev-15 -y
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
ARG ALLOWED_HOSTS
ARG AWS_ACCESS_KEY_ID
ARG AWS_S3_CUSTOM_DOMAIN
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_STORAGE_BUCKET_NAME
ARG AWS_SES_ACCESS_KEY_ID
ARG AWS_SES_SECRET_ACCESS_KEY
ARG CORS_ALLOWED_ORIGINS
ARG DATABASE_HOST
ARG DATABASE_NAME
ARG DATABASE_PASSWORD
ARG DATABASE_PORT
ARG DATABASE_USER
ARG SECRET_KEY
ENV ALLOWED_HOSTS=${ALLOWED_HOSTS}
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_S3_CUSTOM_DOMAIN=${AWS_S3_CUSTOM_DOMAIN}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV AWS_STORAGE_BUCKET_NAME=${AWS_STORAGE_BUCKET_NAME}
ENV AWS_SES_ACCESS_KEY_ID=${AWS_SES_ACCESS_KEY_ID}
ENV AWS_SES_SECRET_ACCESS_KEY=${AWS_SES_SECRET_ACCESS_KEY}
ENV CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS}
ENV DATABASE_HOST=${DATABASE_HOST}
ENV DATABASE_NAME=${DATABASE_NAME}
ENV DATABASE_PASSWORD=${DATABASE_PASSWORD}
ENV DATABASE_PORT=${DATABASE_PORT}
ENV DATABASE_USER=${DATABASE_USER}
ENV SECRET_KEY=${SECRET_KEY}
EXPOSE 8000
RUN ["python", "manage.py", "collectstatic", "--noinput"]
RUN ["python", "manage.py", "migrate"]
CMD ["gunicorn", "--workers=4", "--bind=:8000", "my_app_backend.wsgi"]
< /code>
requirements.txt
Code: Select all
boto3==1.16.18
django==3.1
django-ckeditor==6.0.0
django-cors-headers==3.5.0
django-filter==2.4.0
django-import-export>=2.5.0
django-ses==1.0.3
django-simple-history==2.11.0
django-storages==1.10.1
djangorestframework==3.11.1
djangorestframework-gis==0.16
dj-database-url==0.5.0
gunicorn==20.0.4
Pillow==7.2.0
psycopg2-binary==2.9.10
mysql-connector-python>=8.0.21
timezonefinder>=4.2.0
pytz>=2020.1
< /code>
Between the last working release and this one, I've made the following changes to the Dockerfile
- updated Debian version from FROM andrejreznik/python-gdal:stable to FROM andrejreznik/python-gdal:py3.11.10-gdal3.6.2
- added an explicit PostgreSQL version via RUN apt-get install postgresql-15 postgresql-server-dev-15 -y
Abgesehen von diesen Änderungen sind diese Dateien genau gleich.
Code: Select all
RUN apt-get install gunicorn -y
< /code>
and updating gunicorn