diff --git a/build.sh b/build.sh index 91f25de6..12041c19 100755 --- a/build.sh +++ b/build.sh @@ -222,7 +222,7 @@ bundle_release() { docker build -f docker/backend.Dockerfile -t "${backend_tag}" . echo "[bundle] Building frontend image ${frontend_tag}..." - docker build -f docker/frontend.Dockerfile -t "${frontend_tag}" . + docker build --build-arg "APP_VERSION=${tag}" -f docker/frontend.Dockerfile -t "${frontend_tag}" . echo "[bundle] Building agent image ${agent_tag}..." docker build -f docker/Dockerfile.agent -t "${agent_tag}" . diff --git a/docker/all-in-one.Dockerfile b/docker/all-in-one.Dockerfile index 034b7c9a..d8bcf403 100644 --- a/docker/all-in-one.Dockerfile +++ b/docker/all-in-one.Dockerfile @@ -11,6 +11,8 @@ # ── Stage 1: Build Frontend ──────────────────────────────── FROM node:20-alpine AS frontend-builder +ARG APP_VERSION=0.0.0 +ENV APP_VERSION=${APP_VERSION} WORKDIR /app/frontend diff --git a/docker/frontend.Dockerfile b/docker/frontend.Dockerfile index aa6f85d9..7f79b2a9 100644 --- a/docker/frontend.Dockerfile +++ b/docker/frontend.Dockerfile @@ -10,6 +10,8 @@ # #endregion docker.frontend.Dockerfile FROM node:20-alpine AS build +ARG APP_VERSION=0.0.0 +ENV APP_VERSION=${APP_VERSION} WORKDIR /app/frontend COPY frontend/package*.json ./ diff --git a/frontend/vite.config.js b/frontend/vite.config.js index f7704ec3..0324fc2f 100755 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -3,6 +3,11 @@ import { defineConfig } from 'vite'; import { execSync } from 'child_process'; const APP_VERSION = (() => { + // 1. Use APP_VERSION env var (passed via Docker --build-arg or .env) + if (process.env.APP_VERSION && process.env.APP_VERSION !== '0.0.0') { + return process.env.APP_VERSION; + } + // 2. Fall back to latest git tag (works in local dev with .git) try { return execSync('git describe --tags --abbrev=0', { encoding: 'utf8' }).trim(); } catch {