🔧 Configure KI API URL from environment

With an entrypoint script, fill the configuration template from an
environment variable containing the KI API URL.
This commit is contained in:
nomaster 2024-01-12 18:50:22 +01:00
parent c2552f3c3a
commit d321a0fdce
3 changed files with 25 additions and 0 deletions

View File

@ -18,3 +18,12 @@ LABEL org.opencontainers.image.source=https://git.wtf-eg.de/kompetenzinventar/ki
LABEL org.opencontainers.image.url=https://git.wtf-eg.de/kompetenzinventar/ki-frontend LABEL org.opencontainers.image.url=https://git.wtf-eg.de/kompetenzinventar/ki-frontend
LABEL org.opencontainers.image.documentation=https://git.wtf-eg.de/kompetenzinventar/ki-frontend#docker LABEL org.opencontainers.image.documentation=https://git.wtf-eg.de/kompetenzinventar/ki-frontend#docker
LABEL org.opencontainers.image.vendor="WTF Kooperative eG" LABEL org.opencontainers.image.vendor="WTF Kooperative eG"
ENV KI_BACKEND_URL
WORKDIR /usr/share/nginx/html
ENTRYPOINT ["/entrypoint.sh"]A
COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh /
COPY --from=builder /dist .

9
entrypoint.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -o errexit
: ${KI_API_URL:=http://ki-backend:5000}
sed -e "s%\$KI_API_URL%$KI_API_URL%g" config.js.in > config.js
exec "$@"

7
public/config.js.in Normal file
View File

@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
window.ki = {
apiUrl: "$KI_API_URL"
}