Fixed cross-compilation
This commit is contained in:
+10
-4
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user