-
Notifications
You must be signed in to change notification settings - Fork 2
feat(docker): bake git provenance into image via build-args + export from docker-run #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -129,6 +129,24 @@ fi | |||||||||||||||||||||||||||||||||||||||
| COMPOSE_ARGS=(-f docker-compose.yml) | ||||||||||||||||||||||||||||||||||||||||
| PROFILES=() | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Export build-time git provenance so `docker compose build` can bake it | ||||||||||||||||||||||||||||||||||||||||
| # into the image (consumed by src/utilities/nodeVersion.ts and surfaced | ||||||||||||||||||||||||||||||||||||||||
| # via getNetworkInfo.nodeVersion). Every var has a safe empty default | ||||||||||||||||||||||||||||||||||||||||
| # so a host without git, or a non-repo working tree, still builds. | ||||||||||||||||||||||||||||||||||||||||
| # `git diff-index --quiet HEAD` exits 1 when dirty, 0 when clean; map | ||||||||||||||||||||||||||||||||||||||||
| # to a "true"/"false" string the node module understands. | ||||||||||||||||||||||||||||||||||||||||
| if git -C "$(dirname "${BASH_SOURCE[0]}")/.." rev-parse --git-dir >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||||||||
| GIT_REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||||||||||||||||||||||||||||||||||||||||
| export GIT_COMMIT="$(git -C "$GIT_REPO_DIR" rev-parse HEAD 2>/dev/null || true)" | ||||||||||||||||||||||||||||||||||||||||
| export GIT_BRANCH="$(git -C "$GIT_REPO_DIR" rev-parse --abbrev-ref HEAD 2>/dev/null || true)" | ||||||||||||||||||||||||||||||||||||||||
| if git -C "$GIT_REPO_DIR" diff-index --quiet HEAD 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||
| export GIT_DIRTY="false" | ||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||
| export GIT_DIRTY="true" | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+138
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| export BUILT_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if [[ "$USE_PROXY" == "true" ]]; then | ||||||||||||||||||||||||||||||||||||||||
| if [[ ! -f docker-compose.proxy.yml ]]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "docker-compose.proxy.yml missing — cannot enable proxy mode." >&2 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"HEAD"as branch name in API outputgit rev-parse --abbrev-ref HEADreturns the literal string"HEAD"when the repo is in a detached HEAD state — which is the norm for GitHub Actions, GitLab CI, and most CI/CD checkouts for PRs or tag builds. That string passes the|| nullguard innodeVersion.ts("HEAD"is truthy), so thegetNetworkInforesponse surfaces"branch": "HEAD"instead ofnull, which is indistinguishable from an actual branch namedHEADand offers no useful diagnostic info. Consider filtering the value before export:[[ "$GIT_BRANCH" == "HEAD" ]] && unset GIT_BRANCH(or export empty string) to let the module fall through tonull.