build(Dockerfile): build multiarch image
This commit is contained in:
parent
65bd079691
commit
9013cd548c
1 changed files with 9 additions and 2 deletions
11
Dockerfile
11
Dockerfile
|
|
@ -1,6 +1,10 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG ALPINE_VERSION=3.19
|
||||
|
||||
FROM golang:1.22-alpine${ALPINE_VERSION} AS builder
|
||||
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine${ALPINE_VERSION} AS builder
|
||||
|
||||
ARG BUILDPLATFORM
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
@ -10,7 +14,10 @@ RUN go mod download
|
|||
|
||||
COPY . .
|
||||
|
||||
RUN go build -o yggdrasil ./cmd/yggdrasil
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o yggdrasil ./cmd/yggdrasil
|
||||
|
||||
FROM alpine:${ALPINE_VERSION} AS runtime
|
||||
|
||||
|
|
|
|||
Reference in a new issue