Skip to content

Commit 765251f

Browse files
authored
mirror GoReleaser by passing version ldflag to github action docker build [#253] (#260)
1 parent 47a3e0c commit 765251f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ jobs:
4747
provenance: false
4848
tags: ${{ steps.meta.outputs.tags }}
4949
labels: ${{ steps.meta.outputs.labels }}
50+
build-args: |
51+
VERSION=${{ github.ref_name }}
5052
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=See https://github.com/protomaps/go-pmtiles for more info.

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ FROM golang:1.23-alpine3.19 AS builder
22
COPY . /workspace
33
WORKDIR /workspace
44
ENV CGO_ENABLED=0
5-
RUN go build -o /workspace/go-pmtiles
5+
ARG VERSION
6+
RUN go build \
7+
-trimpath \
8+
-ldflags "\
9+
-s -w \
10+
-X main.version=${VERSION}" \
11+
-o /workspace/go-pmtiles
612
FROM gcr.io/distroless/static
713
COPY --from=builder /workspace/go-pmtiles /go-pmtiles
814
EXPOSE 8080

0 commit comments

Comments
 (0)