Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ jobs:
# stage via buildx cache. Each image is published at
# ghcr.io/<owner>/<binary> with the release tag and `latest`.

# Mirrors GoReleaser's {{.Version}} / {{.Commit}} / {{.Date}} so
# binaries inside the images report the same buildinfo as the
# tarball binaries.
- name: Compute Docker build metadata
run: |
{
echo "BUILD_VERSION=${GITHUB_REF_NAME#v}"
echo "BUILD_COMMIT=${GITHUB_SHA}"
echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
} >> "$GITHUB_ENV"

- name: Docker meta — prosa (CLI)
id: meta-cli
uses: docker/metadata-action@v6
Expand All @@ -101,6 +112,10 @@ jobs:
push: true
tags: ${{ steps.meta-cli.outputs.tags }}
labels: ${{ steps.meta-cli.outputs.labels }}
build-args: |
VERSION=${{ env.BUILD_VERSION }}
COMMIT=${{ env.BUILD_COMMIT }}
BUILD_DATE=${{ env.BUILD_DATE }}

- name: Docker meta — prosa-server
id: meta-server
Expand All @@ -120,6 +135,10 @@ jobs:
push: true
tags: ${{ steps.meta-server.outputs.tags }}
labels: ${{ steps.meta-server.outputs.labels }}
build-args: |
VERSION=${{ env.BUILD_VERSION }}
COMMIT=${{ env.BUILD_COMMIT }}
BUILD_DATE=${{ env.BUILD_DATE }}

- name: Docker meta — prosa-panel
id: meta-panel
Expand All @@ -139,3 +158,7 @@ jobs:
push: true
tags: ${{ steps.meta-panel.outputs.tags }}
labels: ${{ steps.meta-panel.outputs.labels }}
build-args: |
VERSION=${{ env.BUILD_VERSION }}
COMMIT=${{ env.BUILD_COMMIT }}
BUILD_DATE=${{ env.BUILD_DATE }}
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ ARG GO_VERSION=1.26.2
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS build
ARG TARGETOS
ARG TARGETARCH
# Build metadata mirroring the GoReleaser ldflags so image binaries
# report a real version instead of "dev (none, unknown)".
ARG VERSION=dev
ARG COMMIT=none
ARG BUILD_DATE=unknown
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN mkdir -p /out && CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags='-s -w' -o /out/ ./cmd/...
go build -ldflags="-s -w \
-X github.com/c3-oss/prosa/internal/buildinfo.Version=${VERSION} \
-X github.com/c3-oss/prosa/internal/buildinfo.Commit=${COMMIT} \
-X github.com/c3-oss/prosa/internal/buildinfo.BuildDate=${BUILD_DATE}" \
-o /out/ ./cmd/...

FROM gcr.io/distroless/static-debian12 AS prosa
COPY --from=build /out/prosa /usr/local/bin/prosa
Expand Down
15 changes: 14 additions & 1 deletion docs/distribution/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ ARG GO_VERSION=1.26.2
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bookworm AS build
ARG TARGETOS
ARG TARGETARCH
# Build metadata mirroring the GoReleaser ldflags so image binaries
# report a real version instead of "dev (none, unknown)".
ARG VERSION=dev
ARG COMMIT=none
ARG BUILD_DATE=unknown
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN mkdir -p /out && CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags='-s -w' -o /out/ ./cmd/...
go build -ldflags="-s -w \
-X github.com/c3-oss/prosa/internal/buildinfo.Version=${VERSION} \
-X github.com/c3-oss/prosa/internal/buildinfo.Commit=${COMMIT} \
-X github.com/c3-oss/prosa/internal/buildinfo.BuildDate=${BUILD_DATE}" \
-o /out/ ./cmd/...

FROM gcr.io/distroless/static-debian12 AS prosa
COPY --from=build /out/prosa /usr/local/bin/prosa
Expand All @@ -58,6 +67,10 @@ Notes:
`--target` invocations.
- `CGO_ENABLED=0` keeps the binaries static — distroless has no glibc.
- `-s -w` strips debug symbols.
- The release workflow passes `VERSION` / `COMMIT` / `BUILD_DATE` build
args (tag without the `v` prefix, commit SHA, UTC RFC 3339 date) so
`--version` and startup logs match the tarball binaries. Local builds
without the args report `dev (none, unknown)`.
- `--platform=$BUILDPLATFORM` lets Buildx cross-compile from one
builder; `TARGETOS`/`TARGETARCH` come from
`docker buildx build --platform`.
Expand Down
Loading