From 8eb2f4268caaa11e3d452c3df7dd58ef0a982c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=BCrli?= Date: Mon, 5 Feb 2024 13:07:36 +0100 Subject: [PATCH] Feature: Add MAX_UPLOAD_SIZE environment variable to configure the max documentation size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Bürli --- Dockerfile | 9 +++++---- README.md | 9 ++++++++- docat/docat/nginx/default | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70fb19c6e..ff66c2ffb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,9 +36,12 @@ RUN poetry install --no-root --no-ansi --only main # production FROM python:3.12-slim +# defaults +ENV MAX_UPLOAD_SIZE=100M + # set up the system RUN apt update && \ - apt install --yes nginx dumb-init libmagic1 && \ + apt install --yes nginx dumb-init libmagic1 gettext && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/docat/doc @@ -49,10 +52,8 @@ COPY --from=frontend /app/frontend/dist /var/www/html COPY docat /app/docat WORKDIR /app/docat -RUN cp docat/nginx/default /etc/nginx/sites-enabled/default - # Copy the build artifact (.venv) COPY --from=backend /app /app/docat ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["sh", "-c", "nginx && .venv/bin/python -m uvicorn --host 0.0.0.0 --port 5000 docat.app:app"] +CMD ["sh", "-c", "envsubst '$MAX_UPLOAD_SIZE' < /app/docat/docat/nginx/default > /etc/nginx/sites-enabled/default && nginx && .venv/bin/python -m uvicorn --host 0.0.0.0 --port 5000 docat.app:app"] diff --git a/README.md b/README.md index ec196d909..be8918e6e 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Same thing with `docatl`: docatl tag --host http://localhost:8000 PROJECT VERSION latest ``` -## Advanced `config.json` +## Advanced Frontend `config.json` It is possible to configure some things after the fact. @@ -101,3 +101,10 @@ It is possible to configure some things after the fact. Supported config options: - headerHTML + +## Advanced System Config + +Further proxy configurations can be done through the following environmental variables: +| Varaiable | Default (Link to Definition) | Description | +|---|---|---| +| MAX_UPLOAD_SIZE | [100M](./Dockerfile) | Limits the size of individual archives posted to the API | diff --git a/docat/docat/nginx/default b/docat/docat/nginx/default index c90381370..52b354460 100644 --- a/docat/docat/nginx/default +++ b/docat/docat/nginx/default @@ -18,7 +18,7 @@ server { } location /api { - client_max_body_size 100M; + client_max_body_size $MAX_UPLOAD_SIZE; proxy_pass http://python_backend; }