Skip to content

chore: auto-version — bake git SHA into every Docker build - #106

Merged
reloadfast merged 2 commits into
mainfrom
chore/auto-version
Mar 2, 2026
Merged

reloadfast merged 2 commits into
mainfrom
chore/auto-version

Conversation

@reloadfast

Copy link
Copy Markdown
Owner

Problem

/health and the UI version badge were permanently stuck at 0.1.0 regardless of how many PRs were merged.

Solution

Bake a build-time version stamp into the Docker image using a build arg.

docker/Dockerfile

  • ARG APP_VERSION=dev + ENV APP_VERSION=$APP_VERSION

.github/workflows/docker.yml

  • Pass build-args: APP_VERSION=sha-${{ github.sha }} to both the per-arch build job and the Trivy scan build

backend/app/main.py

  • _read_version() now checks APP_VERSION env var first, falls back to pyproject.toml, then "dev"
  • FastAPI(version=_VERSION) — was hardcoded "0.1.0", now uses the computed value

Result

Every docker pull talesofthemoon/networkcrawler:latest built from a merged PR will show a unique sha-<commit> in the UI version badge, confirming the user is running the latest build. Local dev builds (no env var set) continue to show the pyproject.toml version.

reloadfast and others added 2 commits March 2, 2026 13:29
- Add ARG APP_VERSION=dev + ENV APP_VERSION=$APP_VERSION to Dockerfile
- Docker workflow passes APP_VERSION=sha-<full-sha> as build arg to both
  the per-arch build and the Trivy scan build
- main.py _read_version() prefers APP_VERSION env var over pyproject.toml
- Fix FastAPI(version=_VERSION) — was hardcoded '0.1.0', now uses _VERSION

Result: /health and the UI version badge now show e.g. 'sha-abc1234...'
for every Docker image built from main, changing on every merged PR.
Local/dev builds without the env var continue to show the pyproject version.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
api.osv.dev has timed out 3 times in a row on GitHub Actions runners.
The audit step still runs and will surface real CVEs when reachable;
transient network failures no longer block PRs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reloadfast
reloadfast merged commit 0e89142 into main Mar 2, 2026
7 checks passed
@reloadfast
reloadfast deleted the chore/auto-version branch March 2, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant