fix: respect TANDOOR_PORT MEDIA_ROOT and STATIC_ROOT in the nginx config

Signed-off-by: wilmarguida <w.denouden@guida.nl>
This commit is contained in:
wilmarguida
2025-08-05 08:55:02 +02:00
parent b42285a9a5
commit cde03a0f33
3 changed files with 12 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
FROM python:3.13-alpine3.21
#Install all dependencies.
RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap git libgcc libstdc++ nginx tini
RUN apk add --no-cache postgresql-libs postgresql-client gettext zlib libjpeg libwebp libxml2-dev libxslt-dev openldap git libgcc libstdc++ nginx tini envsubst
#Print all logs without buffering it.
ENV PYTHONUNBUFFERED 1

View File

@@ -1,7 +1,11 @@
#!/bin/sh
source venv/bin/activate
TANDOOR_PORT="${TANDOOR_PORT:-8080}"
# these are envsubst in the nginx config, make sure they default to something sensible when unset
export TANDOOR_PORT="${TANDOOR_PORT:-8080}"
export MEDIA_ROOT=${MEDIA_ROOT:-/opt/recipes/mediafiles};
export STATIC_ROOT=${STATIC_ROOT:-/opt/recipes/staticfiles};
GUNICORN_WORKERS="${GUNICORN_WORKERS:-3}"
GUNICORN_THREADS="${GUNICORN_THREADS:-2}"
GUNICORN_LOG_LEVEL="${GUNICORN_LOG_LEVEL:-'info'}"
@@ -91,6 +95,9 @@ chmod -R 755 ${MEDIA_ROOT:-/opt/recipes/mediafiles}
ipv6_disable=$(cat /sys/module/ipv6/parameters/disable)
# prepare nginx config
envsubst '$MEDIA_ROOT $STATIC_ROOT $TANDOOR_PORT' < /opt/recipes/http.d/Recipes.conf.template > /opt/recipes/http.d/Recipes.conf
# start nginx
echo "Starting nginx"
nginx

View File

@@ -7,20 +7,19 @@ server {
# serve media files
location /media {
alias /opt/recipes/mediafiles;
alias ${MEDIA_ROOT};
add_header Content-Disposition 'attachment; filename="$args"';
}
# serve service worker under main path
location = /service-worker.js {
alias /opt/recipes/staticfiles/vue3/service-worker.js;
alias ${STATIC_ROOT}/vue3/service-worker.js;
}
# pass requests for dynamic content to gunicorn
location / {
proxy_set_header Host $http_host;
proxy_pass http://localhost:8080;
proxy_pass http://localhost:${TANDOOR_PORT};
error_page 502 /errors/http502.html;
}