Skip to content

Commit c1e5316

Browse files
committed
fix: use multi-stage build for Go tools in release Dockerfile
Alpine's Go package (1.25.8) is too old for oasdiff@latest which now requires Go >= 1.26. Switch to a multi-stage build that uses the official golang:1.26-alpine image to compile Go-based tools, then copies the binaries into the Alpine runtime stage.
1 parent f009b04 commit c1e5316

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

Dockerfile.goreleaser

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1+
## Stage 1: Build Go-based tools with the official Go toolchain
2+
FROM golang:1.26-alpine AS tools
3+
4+
RUN apk --no-cache add git && \
5+
go install github.com/bufbuild/buf/cmd/buf@latest && \
6+
go install github.com/oasdiff/oasdiff@latest && \
7+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
8+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
9+
10+
## Stage 2: Runtime image
111
FROM alpine:latest
212

313
# dockers_v2 passes TARGETPLATFORM as a build arg (e.g. linux/amd64)
414
ARG TARGETPLATFORM
515

6-
# Install necessary tools
16+
# Install runtime dependencies
717
RUN apk --no-cache add \
818
ca-certificates \
919
git \
1020
protobuf \
1121
nodejs \
12-
npm
22+
npm && \
23+
npm install -g @stoplight/spectral-cli
1324

14-
# Install additional tools
15-
RUN npm install -g @stoplight/spectral-cli
16-
17-
# Install Go-based tools
18-
RUN apk add --no-cache go && \
19-
go install github.com/bufbuild/buf/cmd/buf@latest && \
20-
go install github.com/oasdiff/oasdiff@latest && \
21-
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
22-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && \
23-
apk del go
25+
# Copy Go-based tools from builder
26+
COPY --from=tools /go/bin/ /usr/local/bin/
2427

2528
# Copy the pre-built binary from GoReleaser (dockers_v2 places binaries under $TARGETPLATFORM/)
2629
COPY ${TARGETPLATFORM}/apx /usr/local/bin/apx

0 commit comments

Comments
 (0)