Use granian as a WSGI server

This commit is contained in:
Alexis Métaireau 2024-10-24 01:18:41 +02:00
parent 5a4260ed42
commit 9f8be6d52d
No known key found for this signature in database
GPG key ID: 1C21B876828E5FF2
3 changed files with 14 additions and 16 deletions

View file

@ -31,8 +31,7 @@ RUN apt-get install --no-install-recommends -y tzdata \
libgdk-pixbuf2.0-0 \
shared-mime-info \
gettext \
tini \
uwsgi
tini
# Stage 2: Python environment
FROM linux-base AS python-base
@ -52,6 +51,7 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
COPY pyproject.toml ./
COPY uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project
RUN uv pip install granian
# Stage 3: Building environment
FROM python-base AS builder-base
@ -60,10 +60,12 @@ WORKDIR /app
COPY . /app
# Build static files
RUN python manage.py compilescss
RUN python manage.py collectstatic --no-input
# Compile translation files
RUN python manage.py compilemessages
# RUN python manage.py compilemessages
# Stage 4: Webapp environment
FROM linux-base AS webapp

View file

@ -2,7 +2,13 @@
set -euxo pipefail
echo "Migrate database..."
python manage.py migrate
python manage.py migrate --settings local_settings
echo "Start uwsgi..."
exec uwsgi --ini docker/uwsgi.ini
echo "Start server..."
granian la_chariotte.wsgi:application \
--host 127.0.0.1 \
--port 8000 \
--interface wsgi \
--no-ws \
--loop uvloop

View file

@ -1,10 +0,0 @@
[uwsgi]
http = :$(PORT)
home = /venv
module = la_chariotte.wsgi:application
master = True
vacuum = True
max-requests = 5000
processes = 4
enable-threads = true
buffer-size = 32768