Run gunicorn as "django" user and not as root

pull/27/head
JensDiemer 2020-11-22 14:13:38 +01:00
rodzic 38899ff08b
commit c1a70043fa
3 zmienionych plików z 14 dodań i 10 usunięć

Wyświetl plik

@ -14,6 +14,9 @@ RUN apt-get update \
&& python3 -m pip install -U pip \
&& pip install -U psycopg2-binary
RUN addgroup --system django \
&& adduser --system --no-create-home --disabled-password --ingroup django --shell /bin/bash django
WORKDIR /django
RUN pip install "pyinventory>=0.6.0"

Wyświetl plik

@ -29,20 +29,23 @@ else
pip3 install -U "${PYTHON_PACKAGE_NAME}"
)
fi
GUNICORN_CMD_ARGS=<<'EOF'
--config /django/gunicorn.conf.py
--bind "$(hostname):8000"
--pid="/tmp/gunicorn.pid"
--access-logfile="-"
--error-logfile="-"
--log-level=info
EOF
(
set -x
./manage.py collectstatic --noinput
./manage.py migrate
/usr/local/bin/gunicorn \
--config /django/gunicorn.conf.py \
--bind "$(hostname):8000" \
--pid="/tmp/gunicorn.pid" \
--access-logfile="-" \
--error-logfile="-" \
--log-level=info \
wsgi
su django -c "/usr/local/bin/gunicorn wsgi"
echo "gunicorn terminated with exit code: $?"
sleep 3

Wyświetl plik

@ -2,5 +2,3 @@ import multiprocessing
workers = multiprocessing.cpu_count() * 2 + 1
access_logfile = '-' # log to stdout