Use native Go cross-compilation

This commit is contained in:
Gabe Cook 2025-03-17 22:38:00 -05:00
parent a2fd352bf1
commit 93852060cc
No known key found for this signature in database
GPG key ID: 3197318BDE319B8D

View file

@ -1,14 +1,18 @@
FROM golang:alpine AS builder
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
RUN apk add build-base
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
COPY --from=xx / /
WORKDIR /src
COPY go.mod go.sum .
COPY go.mod go.sum ./
RUN go mod download
COPY . .
WORKDIR /src/cmd/WatchYourLAN
RUN CGO_ENABLED=0 go build -ldflags='-w -s' -o /WatchYourLAN .
ARG TARGETPLATFORM
RUN CGO_ENABLED=0 xx-go build -ldflags='-w -s' -o /WatchYourLAN ./cmd/WatchYourLAN
FROM alpine