From fc41d57107312dd832815f85b76f3b5f286596ae Mon Sep 17 00:00:00 2001 From: maany Date: Tue, 23 Jan 2024 17:11:50 +0100 Subject: [PATCH] webui entrypoint - enable patching - generate environment from env variables --- webui/Dockerfile | 4 ++-- webui/docker-entrypoint.sh | 38 ++++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/webui/Dockerfile b/webui/Dockerfile index 09e8552..d4142c5 100644 --- a/webui/Dockerfile +++ b/webui/Dockerfile @@ -27,10 +27,10 @@ RUN python3 -m pip install --no-cache-dir j2cli WORKDIR /opt/rucio/webui -ENV RUCIO_WEBUI_PATH=$(WORKDIR) +ENV RUCIO_WEBUI_PATH=/opt/rucio/webui RUN curl https://raw.githubusercontent.com/rucio/rucio/master/tools/merge_rucio_configs.py --output /opt/rucio/merge_rucio_configs.py -RUN git clone --depth 1 -b ${TAG} -- https://github.com/rucio/webui.git /opt/rucio/webui +RUN git clone --depth 1 -b ${TAG} -- https://github.com/rucio/webui.git ${RUCIO_WEBUI_PATH} RUN npm install RUN npm run build diff --git a/webui/docker-entrypoint.sh b/webui/docker-entrypoint.sh index 87816b6..2b65a1f 100755 --- a/webui/docker-entrypoint.sh +++ b/webui/docker-entrypoint.sh @@ -1,24 +1,36 @@ #!/bin/bash -e +log() { + echo "$(date -u) [rucio-webui] - $@" +} + +generate_env_file() { + cd tools/env-generator && \ + + npm install liquidjs && \ + npm run build && \ + chmod +x ./dist/generate-env.js && \ + ./dist/generate-env.js make prod ../../.env --write + + echo "Return code: $?" + cd ../.. +} + +echo "=================== /opt/rucio/webui/.env ===================" if [ -f /opt/rucio/webui/.env ]; then - echo "/opt/rucio/webui/.env already mounted." + log "/opt/rucio/webui/.env already mounted." else - echo "/opt/rucio/webui/.env not found. will generate one." - j2 /tmp/.env.default.j2 | sed '/^\s*$/d' > /opt/rucio/webui/.env + log "/opt/rucio/webui/.env not found. Will generate one now." + generate_env_file fi - -echo "=================== /opt/rucio/webui/.env ========================" cat /opt/rucio/webui/.env echo "" if [ -d "/patch" ] then - echo "Patches found. Trying to apply them" - - TMP_PATCH_DIR="$(mktemp -d)" - trap 'rm -rf -- "$TMP_PATCH_DIR"' EXIT # Deletes temp dir when script exits - - for patchfile in /patch/*.patch + echo "=================== Apply Patches ===================" + log "Patches found. Trying to apply them" + for patchfile in /patch/* do echo "Applying patch ${patchfile}" @@ -50,7 +62,9 @@ then fi fi done + log "Rebuilding the Rucio WebUI after applying patches!" + npm run build fi -echo "=================== Starting RUCIO WEBUI ========================" +echo "=================== Starting RUCIO WEBUI ===================" npm run start \ No newline at end of file