From f5bd393a4d6b8b511876148090680e9b09dbaa92 Mon Sep 17 00:00:00 2001 From: imbajin Date: Sun, 12 Jul 2026 17:46:10 +0800 Subject: [PATCH 1/2] refactor(vermeer): cross-compile Docker binaries - pin the Go builder to the native build platform - cross-compile binaries for each requested target platform - cache Go modules and compiler artifacts across builds - isolate UI dependency downloads from source changes --- vermeer/Dockerfile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/vermeer/Dockerfile b/vermeer/Dockerfile index 44da2502b..638fde970 100644 --- a/vermeer/Dockerfile +++ b/vermeer/Dockerfile @@ -14,14 +14,27 @@ # See the License for the specific language governing permissions and # limitations under the License. # -FROM golang:1.23-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder +ARG TARGETOS +ARG TARGETARCH RUN apk add --no-cache npm bash curl -COPY ./ /src/ WORKDIR /src/ ENV CGO_ENABLED="0" + +COPY go.mod go.sum ./ +RUN --mount=type=cache,target=/go/pkg/mod go mod download + +COPY scripts/download_ui_assets.sh ./scripts/ +COPY ui/package.json ./ui/ RUN ./scripts/download_ui_assets.sh -RUN cd asset && go generate -RUN go build -o /go/bin/app + +COPY ./ ./ +RUN --mount=type=cache,target=/go/pkg/mod \ + --mount=type=cache,target=/root/.cache/go-build \ + cd asset && go generate +RUN --mount=type=cache,target=/go/pkg/mod \ + --mount=type=cache,target=/root/.cache/go-build \ + GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /go/bin/app FROM alpine EXPOSE 8080 From 9c4bcb618a4496febdef0d9ba8758741f9ae5585 Mon Sep 17 00:00:00 2001 From: imbajin Date: Sun, 12 Jul 2026 21:47:42 +0800 Subject: [PATCH 2/2] perf(vermeer): scope target build arguments - keep target-neutral preparation cacheable across platforms - expose target OS and architecture only to final compilation - preserve native builder cross-compilation behavior --- vermeer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vermeer/Dockerfile b/vermeer/Dockerfile index 638fde970..daa70b9f7 100644 --- a/vermeer/Dockerfile +++ b/vermeer/Dockerfile @@ -15,8 +15,6 @@ # limitations under the License. # FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder -ARG TARGETOS -ARG TARGETARCH RUN apk add --no-cache npm bash curl WORKDIR /src/ ENV CGO_ENABLED="0" @@ -32,6 +30,8 @@ COPY ./ ./ RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ cd asset && go generate +ARG TARGETOS +ARG TARGETARCH RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /go/bin/app