diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d583c2c..b73433e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -96,6 +96,9 @@ jobs: && 'type=cacheonly' || format('type=image,name={0}/{1},push-by-digest=true,name-canonical=true,push=true', env.REGISTRY, env.IMAGE_NAME) }} + build-args: | + GIT_COMMIT=${{ github.sha }} + BUILD_TIME=${{ github.event.repository.updated_at }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 887bca4..0c7b2cd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -40,6 +40,9 @@ jobs: file: ./Dockerfile push: false tags: ${{ env.IMAGE_NAME }}:test + build-args: | + GIT_COMMIT=${{ github.sha }} + BUILD_TIME=${{ github.event.repository.updated_at }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 7061c60..110db1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends pkg-config \ COPY Cargo.toml Cargo.lock ./ COPY crates ./crates COPY migrations ./migrations +# Build-time metadata baked into the binary via option_env!() macros. +# Pass these with --build-arg GIT_COMMIT=$(git rev-parse --short HEAD) +# and --build-arg BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) at image +# build time so the /health endpoint reports real values instead of "unknown". +ARG GIT_COMMIT="" +ARG BUILD_TIME="" +ENV LUMENQRAPH_GIT_SHA=${GIT_COMMIT} +ENV LUMENQRAPH_BUILD_TIME=${BUILD_TIME} RUN cargo build --release --workspace FROM debian:bookworm-slim@sha256:88200866dfff7ea7f5cbcb6ec7c8a701889efe6fe859fe64d6990e4b07ea4171 AS runtime diff --git a/docker-compose.full.yml b/docker-compose.full.yml index 1ecf117..8696181 100644 --- a/docker-compose.full.yml +++ b/docker-compose.full.yml @@ -4,6 +4,10 @@ # IMPORTANT: Set WEBHOOK_ENCRYPTION_KEY in your environment before starting: # export WEBHOOK_ENCRYPTION_KEY=$(openssl rand -hex 32) # docker compose -f docker-compose.full.yml up --build +# +# Optional: set GIT_COMMIT and BUILD_TIME for accurate /health build info: +# export GIT_COMMIT=$(git rev-parse --short HEAD) +# export BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ) services: postgres: @@ -24,7 +28,11 @@ services: start_period: 10s indexer: - build: . + build: + context: . + args: + GIT_COMMIT: ${GIT_COMMIT:-} + BUILD_TIME: ${BUILD_TIME:-} command: ["lumenqraph-indexer"] restart: unless-stopped depends_on: @@ -38,7 +46,11 @@ services: RUST_LOG: ${RUST_LOG:-info} api: - build: . + build: + context: . + args: + GIT_COMMIT: ${GIT_COMMIT:-} + BUILD_TIME: ${BUILD_TIME:-} command: ["lumenqraph-api"] restart: unless-stopped depends_on: @@ -61,7 +73,11 @@ services: start_period: 10s webhooks: - build: . + build: + context: . + args: + GIT_COMMIT: ${GIT_COMMIT:-} + BUILD_TIME: ${BUILD_TIME:-} command: ["lumenqraph-webhooks"] restart: unless-stopped depends_on: