From 2cf05287307e3781e3bae7884f35a9ba9de61308 Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 28 Mar 2026 19:33:49 +0500 Subject: [PATCH] fix(ui): show version+SHA+build time in footer; fix env not reaching runtime image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PUBLIC_BUILD_VERSION and PUBLIC_BUILD_COMMIT were set only in the builder stage ENV — they were never re-declared in the runtime stage, so the Node server started with them undefined and the badge always showed 'dev'. Fix: re-declare all three ARGs after the second FROM and set runtime ENVs. Add PUBLIC_BUILD_TIME (ISO timestamp from gitea.event.head_commit.timestamp) injected via build-arg in release.yaml. Badge now shows e.g.: v2.3.9+abc1234 · 28 Mar 2026 14:30 UTC --- .gitea/workflows/release.yaml | 1 + ui/Dockerfile | 13 +++++++++++++ ui/src/routes/+layout.svelte | 11 ++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 5f1efd9..903e626 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -218,6 +218,7 @@ jobs: build-args: | BUILD_VERSION=${{ steps.meta.outputs.version }} BUILD_COMMIT=${{ gitea.sha }} + BUILD_TIME=${{ gitea.event.head_commit.timestamp }} cache-from: type=registry,ref=${{ secrets.DOCKER_USER }}/libnovel-ui:latest cache-to: type=inline diff --git a/ui/Dockerfile b/ui/Dockerfile index 582885c..36e29a8 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -14,10 +14,12 @@ COPY . . # Build-time version info — injected by docker-compose or CI via --build-arg. ARG BUILD_VERSION=dev ARG BUILD_COMMIT=unknown +ARG BUILD_TIME=unknown # Expose as PUBLIC_ env vars so SvelteKit's $env/dynamic/public can read them. ENV PUBLIC_BUILD_VERSION=$BUILD_VERSION ENV PUBLIC_BUILD_COMMIT=$BUILD_COMMIT +ENV PUBLIC_BUILD_TIME=$BUILD_TIME RUN npm run build @@ -40,5 +42,16 @@ ENV NODE_ENV=production ENV PORT=3000 ENV HOST=0.0.0.0 +# Carry build-time metadata into the runtime image so the UI footer can +# display the version, commit SHA, and build timestamp. +# These must be re-declared after the second FROM — ARG values do not +# cross stage boundaries, but ENV values set here persist at runtime. +ARG BUILD_VERSION=dev +ARG BUILD_COMMIT=unknown +ARG BUILD_TIME=unknown +ENV PUBLIC_BUILD_VERSION=$BUILD_VERSION +ENV PUBLIC_BUILD_COMMIT=$BUILD_COMMIT +ENV PUBLIC_BUILD_TIME=$BUILD_TIME + EXPOSE $PORT CMD ["node", "build"] diff --git a/ui/src/routes/+layout.svelte b/ui/src/routes/+layout.svelte index c9a45c6..db4231e 100644 --- a/ui/src/routes/+layout.svelte +++ b/ui/src/routes/+layout.svelte @@ -433,7 +433,15 @@ DMCA © {new Date().getFullYear()} libnovel - + + {#snippet buildTime()} + {#if env.PUBLIC_BUILD_TIME && env.PUBLIC_BUILD_TIME !== 'unknown'} + {@const d = new Date(env.PUBLIC_BUILD_TIME)} + + · {d.toUTCString().replace(' GMT', ' UTC').replace(/:\d\d /, ' ')} + + {/if} + {/snippet}
{#if env.PUBLIC_BUILD_VERSION && env.PUBLIC_BUILD_VERSION !== 'dev'} {env.PUBLIC_BUILD_VERSION} @@ -442,6 +450,7 @@ >+{env.PUBLIC_BUILD_COMMIT.slice(0, 7)} {/if} + {@render buildTime()} {:else} dev {/if}