diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 9c317e30b..170a0184d 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -3,7 +3,7 @@ services: image: postgres:15.2-bullseye container_name: zf_postgresdb ports: - - 5432:5432 + - 127.0.0.1:5432:5432 volumes: - pg_data_zimfarm:/var/lib/postgresql/data - ./postgres-initdb:/docker-entrypoint-initdb.d @@ -14,16 +14,22 @@ services: backend: build: ../dispatcher/backend container_name: zf_backend - command: python main.py + command: + - gunicorn + - --conf + - /app/gunicorn_conf.py + - --bind + - 0.0.0.0:8000 + - --reload + - main volumes: - ../dispatcher/backend/src:/app - ../dispatcher/backend/prestart.sh:/app/prestart.sh - ../dispatcher/backend/docs:/app/docs - ../dispatcher/backend/maint-scripts:/app/maint-scripts ports: - - 8000:8000 + - 127.0.0.1:8000:8000 environment: - BINDING_HOST: 0.0.0.0 DEBUG: 1 JWT_SECRET: DH8kSxcflUVfNRdkEiJJCn2dOOKI3qfw POSTGRES_URI: postgresql+psycopg://zimfarm:zimpass@postgresdb:5432/zimfarm @@ -36,7 +42,7 @@ services: volumes: - ../dispatcher/frontend-ui/src:/app ports: - - 8001:80 + - 127.0.0.1:8001:80 environment: ZIMFARM_WEBAPI: http://localhost:8000/v1 depends_on: diff --git a/dispatcher/backend/Dockerfile b/dispatcher/backend/Dockerfile index 6a49b6f76..92f15f592 100644 --- a/dispatcher/backend/Dockerfile +++ b/dispatcher/backend/Dockerfile @@ -1,9 +1,8 @@ -FROM rgaudin/uwsgi-nginx:python3.8 +FROM python:3.8-slim-bookworm LABEL zimfarm=true LABEL org.opencontainers.image.source https://github.com/openzim/zimfarm -RUN pip install --no-cache-dir -U pip -RUN pip install --no-cache-dir uwsgi==2.0.18 +RUN pip install --no-cache-dir -U pip gunicorn==21.2.0 COPY requirements.txt /app/ RUN pip install --no-cache-dir -r /app/requirements.txt @@ -16,16 +15,6 @@ WORKDIR /app/ ENV DOCS_DIR /app/docs ENV INIT_PASSWORD admin -# from uwsgi-nginx -ENV UWSGI_INI /app/uwsgi.ini -ENV UWSGI_CHEAPER 4 -ENV UWSGI_CHEAPER_STEP 2 -ENV UWSGI_PROCESSES 32 -ENV NGINX_MAX_UPLOAD 0 -ENV NGINX_WORKER_PROCESSES 1 -ENV LISTEN_PORT 80 -ENV NGINV_ENABLE_GZIP 1 - # mailgun for notifications ENV MAILGUN_API_URL https://api.mailgun.net/v3/mg.farm.openzim.org ENV MAILGUN_FROM Zimfarm @@ -52,3 +41,5 @@ RUN chmod +x /app/prestart.sh COPY supervisor-listener.py /usr/local/bin/supervisor-listener RUN chmod +x /usr/local/bin/supervisor-listener COPY periodic.conf /etc/supervisor/conf.d/periodic.conf + +CMD ["gunicorn", "--conf", "/app/gunicorn_conf.py", "--bind", "0.0.0.0:8000", "main"] \ No newline at end of file diff --git a/dispatcher/backend/src/gunicorn_conf.py b/dispatcher/backend/src/gunicorn_conf.py new file mode 100644 index 000000000..4aa8ac112 --- /dev/null +++ b/dispatcher/backend/src/gunicorn_conf.py @@ -0,0 +1,9 @@ +# Gunicorn config variables +loglevel = "info" +errorlog = "-" # stderr +accesslog = "-" # stdout +worker_tmp_dir = "/dev/shm" +graceful_timeout = 60 +timeout = 60 +keepalive = 5 +threads = 3