mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-11 12:28:54 +00:00
fix(deploynotify): read commit SHA from Coolify SOURCE_COMMIT runtime env
Baking SOURCE_COMMIT as a Docker build arg never worked: Coolify exposes it as a runtime env var, not a build arg, so gitSHA was always empty and the owner DM was skipped. Read SOURCE_COMMIT from the container env at startup (falling back to the ldflags-baked gitSHA for local builds), forward it via the compose environment, and drop the dead build-arg baking.
This commit is contained in:
1 parent
1fa549fa18
commit
0abd33cb42
6 files changed
+55
-22
No files matched your search
+4
-8
@@ -6,15 +6,11 @@ RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
# SOURCE_COMMIT is baked into the binary so internal/deploynotify can DM the
|
||||
# owner once per new version (parity with the Makefile build). Coolify exposes
|
||||
# the commit SHA as the SOURCE_COMMIT build arg automatically — no manual
|
||||
# wiring needed. For a manual build, pass it with
|
||||
# --build-arg SOURCE_COMMIT=$(git rev-parse --short HEAD)
|
||||
# When unset, deploynotify treats the empty SHA as "stay silent".
|
||||
ARG SOURCE_COMMIT=""
|
||||
# The deploy-notify commit SHA comes from the SOURCE_COMMIT runtime env that
|
||||
# Coolify injects into the container (see docker-compose.yml), not from a build
|
||||
# arg — Coolify does not pass build args here. The binary is built plain.
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||
-ldflags="-s -w -X main.gitSHA=${SOURCE_COMMIT}" \
|
||||
-ldflags="-s -w" \
|
||||
-o /out/server \
|
||||
./cmd/server
|
||||
|
||||
|
||||
Reference in new issue
Block a user