Skip to content

Commit 076fd6f

Browse files
athul-rsclaude
andauthored
UN-2265 [FEAT] Show the running platform version on the profile page (#2034)
* UN-2265 Display platform version in the frontend profile page Bake the build VERSION into the frontend image as UNSTRACT_APPS_VERSION (same pattern as backend.Dockerfile), surface it through the runtime config injected at container start, and show it as a 'Platform Version' field on the profile page. Production CI already passes *.args.VERSION to all images via docker bake, so published images carry the real version on every deployment target; the field is hidden when no version is available (e.g. local npm start). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * UN-2265 Address review: empty VERSION default, escape value in runtime config - ARG VERSION defaults to empty so images built without a version hide the field instead of showing 'dev' - Escape backslashes/quotes before embedding the version in the generated JS * UN-2265 [FIX] Source platform version from runtime env, not baked image RC->stable promotion re-tags images (it does not rebuild), so a version baked into the frontend image at build time would stay frozen at the rc tag after promotion. Drop the frontend.Dockerfile ARG/ENV baking and instead supply UNSTRACT_APPS_VERSION from docker-compose using ${VERSION} -- the same value that already tags the image, so the displayed version always matches what runs. Addresses review from @ritwik-g / @ejhari (version must come dynamically from compose in OSS and the Helm chart in Enterprise). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 71c55e5 commit 076fd6f

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

docker/docker-compose.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ services:
144144
- reverse-proxy
145145
environment:
146146
- ENVIRONMENT=development
147+
# Running platform version, surfaced on the profile page. Reuses the same
148+
# ${VERSION} that tags the image, so it always matches what's deployed
149+
# (and updates on RC->stable promotion, which only retags — doesn't rebuild).
150+
- UNSTRACT_APPS_VERSION=${VERSION}
147151
labels:
148152
- traefik.enable=true
149153
- traefik.http.routers.frontend.rule=Host(`frontend.unstract.localhost`) && !PathPrefix(`/api/v1`) && !PathPrefix(`/deployment`) && !PathPrefix(`/public`)

frontend/generate-runtime-config.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55

66
# Generate the runtime-config.js file with the current environment variables
77
# Note: Using VITE_ prefix for Vite compatibility, fallback to REACT_APP_ for backward compatibility
8+
9+
# Escape backslashes and double quotes so values stay valid inside JS strings
10+
js_escape() {
11+
printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'
12+
}
13+
14+
APP_VERSION=$(js_escape "${UNSTRACT_APPS_VERSION:-}")
15+
816
cat > /usr/share/nginx/html/config/runtime-config.js << EOF
917
// This file is auto-generated at runtime. Do not modify manually.
1018
window.RUNTIME_CONFIG = {
1119
faviconPath: "${VITE_FAVICON_PATH:-${REACT_APP_FAVICON_PATH}}",
1220
logoUrl: "${VITE_CUSTOM_LOGO_URL:-${REACT_APP_CUSTOM_LOGO_URL}}",
13-
enablePosthog: "${VITE_ENABLE_POSTHOG:-${REACT_APP_ENABLE_POSTHOG}}"
21+
enablePosthog: "${VITE_ENABLE_POSTHOG:-${REACT_APP_ENABLE_POSTHOG}}",
22+
version: "${APP_VERSION}"
1423
};
1524
EOF
1625

frontend/src/components/profile/Profile.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useNavigate } from "react-router-dom";
1111
import "./Profile.css";
1212

1313
import { OrganizationIcon } from "../../assets";
14+
import config from "../../config";
1415
import { useAxiosPrivate } from "../../hooks/useAxiosPrivate";
1516
import { useAlertStore } from "../../store/alert-store.js";
1617
import { useSessionStore } from "../../store/session-store.js";
@@ -234,6 +235,18 @@ function Profile() {
234235
</Typography.Text>
235236
</div>
236237
)}
238+
{config.version && (
239+
<div className="field-group">
240+
<Typography.Text type="secondary" className="field-label">
241+
Platform Version
242+
</Typography.Text>
243+
<div className="field-box">
244+
<Typography.Text className="field-value">
245+
{config.version}
246+
</Typography.Text>
247+
</div>
248+
</div>
249+
)}
237250
</Space>
238251
</Card>
239252
</Col>

frontend/src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const config = {
1717
import.meta.env.VITE_FAVICON_PATH ||
1818
"/favicon.ico",
1919
logoUrl: runtimeConfig.logoUrl || import.meta.env.VITE_CUSTOM_LOGO_URL,
20+
version: runtimeConfig.version || import.meta.env.VITE_VERSION,
2021
// Add more values as OR case, if needed for fallback.
2122
};
2223

0 commit comments

Comments
 (0)