PR #175 merged: fix: use Coolify SOURCE_COMMIT build arg for Sentry release tag
TL;DR
The canonical Coolify pattern, after three failed attempts. Requires Stu to flick one toggle in the Coolify UI for this to work end-to-end — details below.
Root cause
Per the Coolify Dockerfile build-pack docs:
By default, SOURCE_COMMIT is excluded from the build to preserve Docker's build cache. You can enable this in the Advanced menu if needed.
So Coolify does auto-inject SOURCE_COMMIT as a Docker build arg — but only when the "Include Source Commit in Build" toggle is flipped on per-app in Advanced settings. The Dockerfile also has to declare ARG SOURCE_COMMIT to expose the injected value inside the build context.
PRs #171–#173 tried to bypass this with in-process git rev-parse calls, both in vite.config.ts and inside RUN in the Dockerfile. None of those worked on Coolify (still TBD why git failed in their build context specifically — local Orbstack repros all succeeded). The toggle is the documented happy path.
Changes
Dockerfile— declareARG SOURCE_COMMIT=""in the frontend-build stage right beforeRUN npm run build:ssr, pass it through as an env var, and echo it so the deploy log shows what we got. Removed the diagnostic noise from #173.vite.config.ts— drop theexecFileSync('git', ...)fallback that never worked inside the Coolify build. Just readprocess.env.SOURCE_COMMIT, fall to'dev'if absent (local dev).
Verified locally with Orbstack
| Build invocation | Bundle contains |
|---|---|
docker build --build-arg SOURCE_COMMIT=deadbeef12345678 | tidylinker@deadbeef1234 ✓ |
docker build (no arg) | no tag, release falls to dev ✓ |
This is the EXACT command Coolify runs internally when the toggle is on.
Required ops step — Stu does this ONCE via UI
For BOTH apps:
- staging (
tidylinker-staging, uuidf84cgg80ko88og4oogkcsg8k) - prod (
tidylinker-laravel, uuidhcow00oos8cwcsscc08okckk)
→ Advanced settings → enable "Include Source Commit in Build" → save.
Then redeploy. Subsequent commits will have a per-commit release tag.
Test plan
- Local:
docker build --build-arg SOURCE_COMMIT=...bakes the SHA into the bundle - Local: no build-arg → bundle release stays
dev(no leakage) - Stu flicks the toggle on staging
- Staging auto-deploys from this merge;
docker execinto the new container, grep the bundle fortidylinker@<sha>— must match the merge commit - Sentry → Releases page shows the new release with uploaded artifacts
- Stu flicks the toggle on prod, prod deploys, same verification
Aftermath / cleanup
If this works as expected, the three Sentry frontend issues (3Q login insertBefore, 3N FormData on /, 3C HttpNetworkError) will become localisable in Sentry because the released maps will match the events.