Fixed cross-compilation
This commit is contained in:
+10
-4
@@ -19,18 +19,24 @@
|
||||
FROM golang:1.26-alpine AS build
|
||||
|
||||
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
|
||||
|
||||
# Only what the server is built from, so a change to the clients, the
|
||||
# Android app or the docs does not invalidate this layer.
|
||||
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 internal ./internal
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||
-trimpath \
|
||||
-ldflags "-s -w -X main.Version=${VERSION}" \
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath \
|
||||
-ldflags="-s -w -X main.version=${APP_VERSION}" \
|
||||
-o /out/keeporgd ./cmd/keeporgd
|
||||
|
||||
# Empty directories to copy into the scratch image with the right owner.
|
||||
|
||||
Reference in New Issue
Block a user