mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-28 01:16:33 +00:00
Coolify pulls from GitHub and runs docker compose build — no guaranteed env vars like SOURCE_COMMIT. Previous approach relied on ARG/ENV passthrough that silently defaulted to "dev". Fix: install git in the builder stage, COPY .git into context, run git describe --tags --always to derive the version, write it to /app/server/.bf-version. version.ts reads this file as a fallback between env vars and the "dev" literal. Chain: BF_SERVER_VERSION env → BF_BUILD_VERSION env → .bf-version file → COOLIFY_GIT_COMMIT env → SOURCE_COMMIT env → "dev". Also: fix .gitignore for rauc-signing/ (was under wrong path).
21 lines
465 B
TypeScript
21 lines
465 B
TypeScript
import { readFileSync } from "node:fs";
|
|
|
|
const BAKED_VERSION = (() => {
|
|
try {
|
|
const v = readFileSync("/app/server/.bf-version", "utf8").trim();
|
|
return v && v !== "dev" ? v : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
})();
|
|
|
|
export function serverVersion(): string {
|
|
return (
|
|
process.env.BF_SERVER_VERSION
|
|
|| process.env.BF_BUILD_VERSION
|
|
|| BAKED_VERSION
|
|
|| process.env.COOLIFY_GIT_COMMIT
|
|
|| process.env.SOURCE_COMMIT
|
|
|| "dev"
|
|
);
|
|
}
|