Fixed cross-compilation
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful

This commit is contained in:
Reactorcoremeltdown
2026-11-02 16:44:42 +01:00
parent cc1aeb6a00
commit e999e353f7
+10 -4
View File
@@ -19,18 +19,24 @@
FROM golang:1.26-alpine AS build FROM golang:1.26-alpine AS build
ARG VERSION=dev ARG VERSION=dev
# The platform being built for, so `go build` cross-compiles to it rather than to
# the builder's own architecture.
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src WORKDIR /src
# Only what the server is built from, so a change to the clients, the # Only what the server is built from, so a change to the clients, the
# Android app or the docs does not invalidate this layer. # Android app or the docs does not invalidate this layer.
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY cmd/keeporgd ./cmd/keeporgd COPY cmd/keeporgd ./cmd/keeporgd
COPY internal ./internal COPY internal ./internal
RUN CGO_ENABLED=0 GOOS=linux go build \ RUN --mount=type=cache,target=/go/pkg/mod \
-trimpath \ --mount=type=cache,target=/root/.cache/go-build \
-ldflags "-s -w -X main.Version=${VERSION}" \ CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath \
-ldflags="-s -w -X main.version=${APP_VERSION}" \
-o /out/keeporgd ./cmd/keeporgd -o /out/keeporgd ./cmd/keeporgd
# Empty directories to copy into the scratch image with the right owner. # Empty directories to copy into the scratch image with the right owner.