fix(web): take git SHA from Coolify's runtime SOURCE_COMMIT
The .git-COPY approach froma35e6c9never actually deployed: BuildKit rejected `COPY .git /tmp/.git` with "failed to calculate checks" because Coolify's build context doesn't include .git, so deploy 86 failed and the stale0144cb2image kept serving "build dev" in the footer. Coolify v4 already injects SOURCE_COMMIT into the container env at runtime by default (build-time only on opt-in, since it busts the build cache by definition). Map SOURCE_COMMIT → GIT_COMMIT in docker-compose, drop the build-time SHA stamping (and the repo-root build context that only existed to reach .git), and shrink _read_git_commit to a one-liner getenv. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a35e6c9c69
commit
6eada58629
3 changed files with 10 additions and 41 deletions
|
|
@ -61,19 +61,7 @@ ANTHROPIC_API_KEY: str = getenv("ANTHROPIC_API_KEY", "")
|
|||
ANTHROPIC_MODEL: str = getenv("ANTHROPIC_MODEL", "claude-haiku-4-5-20251001")
|
||||
|
||||
# --- Build info --------------------------------------------------------------
|
||||
# The Dockerfile writes /git_commit at build time by parsing the repo's .git
|
||||
# dir (Coolify doesn't expose the SHA as an env var). Env GIT_COMMIT overrides
|
||||
# the file so local dev can fake a value. Rendered in the site footer so the
|
||||
# running commit is visible at a glance.
|
||||
def _read_git_commit() -> str:
|
||||
env_val = getenv("GIT_COMMIT", "").strip()
|
||||
if env_val:
|
||||
return env_val
|
||||
try:
|
||||
with open("/git_commit") as _f:
|
||||
return _f.read().strip() or "dev"
|
||||
except OSError:
|
||||
return "dev"
|
||||
|
||||
|
||||
GIT_COMMIT: str = _read_git_commit()
|
||||
# Coolify injects SOURCE_COMMIT into the container's runtime env on every
|
||||
# deploy; docker-compose.yml maps it to GIT_COMMIT. Rendered in the site
|
||||
# footer so the running commit is visible at a glance.
|
||||
GIT_COMMIT: str = getenv("GIT_COMMIT", "").strip() or "dev"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue