From 7bba73ceaec6976c6528c0b5d9646ed5126b3230 Mon Sep 17 00:00:00 2001 From: Mic Szillat Date: Fri, 12 Jan 2024 18:50:22 +0100 Subject: [PATCH] :wrench: Configure KI API URL from environment With an entrypoint script, fill the configuration template from an environment variable containing the KI API URL. --- Dockerfile | 8 ++++++++ configure.sh | 10 ++++++++++ public/config.js.in | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100755 configure.sh create mode 100644 public/config.js.in diff --git a/Dockerfile b/Dockerfile index 504781d..fda9e6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,3 +18,11 @@ 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.documentation=https://git.wtf-eg.de/kompetenzinventar/ki-frontend#docker LABEL org.opencontainers.image.vendor="WTF Kooperative eG" + +ENV KI_API_URL http://ki-backend:5000 + +WORKDIR /usr/share/nginx/html + +COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf +COPY configure.sh /docker-entrypoint.d/ +COPY --from=builder /dist . diff --git a/configure.sh b/configure.sh new file mode 100755 index 0000000..f81b9e8 --- /dev/null +++ b/configure.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -o errexit +set +x + +: ${KI_API_URL:=http://ki-backend:5000} + +sed -e "s%\$KI_API_URL%$KI_API_URL%g" /usr/share/nginx/html/config.js.in > /usr/share/nginx/html/config.js + +exec "$@" diff --git a/public/config.js.in b/public/config.js.in new file mode 100644 index 0000000..fbaf4e2 --- /dev/null +++ b/public/config.js.in @@ -0,0 +1,7 @@ +// SPDX-FileCopyrightText: WTF Kooperative eG +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +window.ki = { + apiUrl: "$KI_API_URL" +}