From a160767dba3678cd62b9b8f4e3cb5eb643c832a0 Mon Sep 17 00:00:00 2001 From: Marcel Johannesmann Date: Thu, 15 Oct 2026 22:48:07 +0200 Subject: [PATCH 1/5] feat: allow a configurable upstream for the frontend webserver This enables setups which do deviate from the default docker-compose and it's networking config. --- docker-compose.dev.yml | 2 ++ docker-compose.e2e.yml | 2 ++ docker-compose.yml | 2 ++ frontend/Dockerfile | 2 +- frontend/{nginx.conf => nginx.conf.template} | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) rename frontend/{nginx.conf => nginx.conf.template} (95%) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2b09470f..3e0d1ffd 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -31,6 +31,8 @@ services: ports: - "8001:80" restart: unless-stopped + environment: + BACKEND_ADDR: http://backend:8000 mailpit: image: axllent/mailpit:latest diff --git a/docker-compose.e2e.yml b/docker-compose.e2e.yml index 76609f38..ff887ee6 100644 --- a/docker-compose.e2e.yml +++ b/docker-compose.e2e.yml @@ -35,6 +35,8 @@ services: depends_on: backend: condition: service_healthy + environment: + BACKEND_ADDR: http://backend:8000 test-runner: build: diff --git a/docker-compose.yml b/docker-compose.yml index 6e1bb0d0..6a8ede77 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,3 +17,5 @@ services: ports: - "8001:80" restart: unless-stopped + environment: + BACKEND_ADDR: http://backend:8000 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 03c231d1..70e437dd 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -17,5 +17,5 @@ RUN npm run build # Stage 2: serve FROM nginx:alpine COPY --from=builder /app/build /usr/share/nginx/html -COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf.template /etc/nginx/templates/ EXPOSE 80 diff --git a/frontend/nginx.conf b/frontend/nginx.conf.template similarity index 95% rename from frontend/nginx.conf rename to frontend/nginx.conf.template index fa87c980..84b0f576 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf.template @@ -7,7 +7,7 @@ server { # API proxy to backend service inside docker network. location /api/ { - proxy_pass http://backend:8000; + proxy_pass ${BACKEND_ADDR}; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; From 537edba4aafc64b5b83c356f67f942261529f39e Mon Sep 17 00:00:00 2001 From: Marcel Johannesmann Date: Thu, 15 Oct 2026 22:48:21 +0200 Subject: [PATCH 2/5] docs: describe BACKEND_ADDR --- docs/guide/configuration.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index ea39a248..96711d98 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -105,11 +105,19 @@ To opt out entirely: TELEMETRY_DISABLED=true ``` -## Frontend Build +## Frontend -| Variable | Description | Default | -|----------|-------------|---------| -| `PUBLIC_DEFAULT_LOCALE` | Default UI language (`en`, `de`, `zh`, `es`, or `fr`) | `en` | +### Run Time + +| Variable | Description | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| `BACKEND_ADDR` | Configures the upstream address for the Nginx webserver. For the default `docker-compose.yml` this is set to `http://backend:8000` | + +### Build Time + +| Variable | Description | Default | +| ----------------------- | ----------------------------------------------------- | ------- | +| `PUBLIC_DEFAULT_LOCALE` | Default UI language (`en`, `de`, `zh`, `es`, or `fr`) | `en` | ## Import Limits From a0622770fef4a807d53af19a4830f719c0c22661 Mon Sep 17 00:00:00 2001 From: Marcel Johannesmann Date: Thu, 15 Oct 2026 23:05:00 +0200 Subject: [PATCH 3/5] fix: use default.conf for config --- frontend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 70e437dd..36bb3f4c 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -17,5 +17,5 @@ RUN npm run build # Stage 2: serve FROM nginx:alpine COPY --from=builder /app/build /usr/share/nginx/html -COPY nginx.conf.template /etc/nginx/templates/ +COPY nginx.conf.template /etc/nginx/templates/default.conf.template EXPOSE 80 From 912186f1ede169638cb86892477032ec20a66780 Mon Sep 17 00:00:00 2001 From: Marcel Johannesmann Date: Sat, 17 Oct 2026 16:36:35 +0200 Subject: [PATCH 4/5] chore: addressed feedback --- docker-compose.dev.yml | 2 +- docker-compose.yml | 2 +- docs/guide/configuration.md | 2 +- docs/releases.md | 9 +++++++++ frontend/Dockerfile | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 3e0d1ffd..5c810ce9 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -32,7 +32,7 @@ services: - "8001:80" restart: unless-stopped environment: - BACKEND_ADDR: http://backend:8000 + BACKEND_ADDR: ${BACKEND_ADDR:-http://backend:8000} mailpit: image: axllent/mailpit:latest diff --git a/docker-compose.yml b/docker-compose.yml index 6a8ede77..01df94fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,4 +18,4 @@ services: - "8001:80" restart: unless-stopped environment: - BACKEND_ADDR: http://backend:8000 + BACKEND_ADDR: ${BACKEND_ADDR:-http://backend:8000} diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 96711d98..7acfe5ab 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -111,7 +111,7 @@ TELEMETRY_DISABLED=true | Variable | Description | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| `BACKEND_ADDR` | Configures the upstream address for the Nginx webserver. For the default `docker-compose.yml` this is set to `http://backend:8000` | +| `BACKEND_ADDR` | Configures the upstream address for the Nginx webserver. For the default `docker-compose.yml` this is set to `http://backend:8000`. **NOTE**: Remove trailing `/` as they might interfere with NGINXs routing behavior. | ### Build Time diff --git a/docs/releases.md b/docs/releases.md index 275785df..76b75582 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -16,6 +16,7 @@ LibrisLog v1.9.0 brings shareable public profile pages, edition grouping and an | Version | Date | Type | |---|---|---| +[UNRELEASED](#unreleased)|-|-| | [v1.9.0](#v1-9-0-smarter-import-search-input-ux) | 2026-09-15 | Feature release | | [v1.8.0](#v1-8-0-camera-zoom-control-optional-telemetry) | 2026-09-02 | Feature release | | [v1.7.0](#v1-7-0-reading-streaks-goals) | 2026-08-26 | Feature release | @@ -33,6 +34,14 @@ LibrisLog v1.9.0 brings shareable public profile pages, edition grouping and an | [v1.1.0](#v1-1-0-polish-missing-covers) | 2026-05-31 | Feature release | | [v1.0.0](#v1-0-0-initial-release) | 2026-05-28 | Initial release | +--- +## UNRELEASED + +**Features** +- 🌐 Allow a configurable backend address via `BACKEND_ADDR` for setups besides the default `docker-compose.yml` + +[Compare with v1.9.0](https://github.com/codebude/librislog/compare/v1.9.0...main) + --- ## v1.9.0: Smarter Import Search & Input UX diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 36bb3f4c..45edf6f5 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -18,4 +18,5 @@ RUN npm run build FROM nginx:alpine COPY --from=builder /app/build /usr/share/nginx/html COPY nginx.conf.template /etc/nginx/templates/default.conf.template +ENV BACKEND_ADDR=http://backend:8000 EXPOSE 80 From 1f96ead098fcb206675534618eb7e520fb89d852 Mon Sep 17 00:00:00 2001 From: codebude Date: Sun, 18 Oct 2026 00:17:47 +0200 Subject: [PATCH 5/5] Warn about invalid BACKEND_ADDR values --- frontend/Dockerfile | 1 + .../10-warn-backend-addr.sh | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 frontend/docker-entrypoint.d/10-warn-backend-addr.sh diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 45edf6f5..c5f2e5d3 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -18,5 +18,6 @@ RUN npm run build FROM nginx:alpine COPY --from=builder /app/build /usr/share/nginx/html COPY nginx.conf.template /etc/nginx/templates/default.conf.template +COPY docker-entrypoint.d/ /docker-entrypoint.d/ ENV BACKEND_ADDR=http://backend:8000 EXPOSE 80 diff --git a/frontend/docker-entrypoint.d/10-warn-backend-addr.sh b/frontend/docker-entrypoint.d/10-warn-backend-addr.sh new file mode 100755 index 00000000..1327ca73 --- /dev/null +++ b/frontend/docker-entrypoint.d/10-warn-backend-addr.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Warns about BACKEND_ADDR values that would break API routing. +# +# nginx treats a URI part in proxy_pass (a trailing slash) as a prefix to replace, +# so "http://backend:8000/" forwards a request for /api/books as /books and every +# API call returns 404 while nginx itself starts cleanly. +# +# The value cannot be corrected here. envsubst only substitutes variables verbatim, +# and the image runs each script in /docker-entrypoint.d as a separate process, so an +# export from this script never reaches the later envsubst call. Printing is the only +# thing that works without replacing the image entrypoint or giving up nginx's +# startup-time upstream validation. +# +# The numbered filename makes this run before 20-envsubst-on-templates.sh. + +BACKEND_ADDR="${BACKEND_ADDR-}" + +case "$BACKEND_ADDR" in + "") + echo "librislog: BACKEND_ADDR is empty, so nginx renders an invalid proxy_pass and will not start." >&2 + echo "librislog: set it to an address such as http://backend:8000." >&2 + ;; + */) + echo "librislog: BACKEND_ADDR ends with a slash ('$BACKEND_ADDR')." >&2 + echo "librislog: nginx replaces the matched location prefix, so /api/books is forwarded as /books and every API call returns 404." >&2 + echo "librislog: drop the trailing slash." >&2 + ;; +esac + +exit 0