fix(version): inject APP_VERSION via Docker build-arg instead of git describe
In Docker builds, .git directory is not available in the container,
so git describe --tags fails and fallback is '0.0.0'. Now:
- build.sh passes --build-arg APP_VERSION=${tag} to frontend build
- Dockerfile accepts ARG APP_VERSION and sets ENV
- vite.config.js checks process.env.APP_VERSION first, then git describe
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user