From 4dd0ac45904413cb0f441321c268ea2c24eb11c7 Mon Sep 17 00:00:00 2001 From: Johannes Edmeier Date: Fri, 20 Oct 2023 22:38:35 +0200 Subject: [PATCH] build: use cross-compilation build instead of emulated build for faster docker build for more information: https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a363693..a603001 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,22 +3,23 @@ ## ## Build ## -FROM golang:1.20-alpine AS build +FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS build +ARG TARGETOS TARGETARCH ARG NAME ARG VERSION ARG REVISION WORKDIR /app +RUN apk add build-base COPY go.mod ./ COPY go.sum ./ RUN go mod download COPY . . -RUN apk add build-base -RUN go build \ +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build \ -ldflags="\ -X 'github.com/steadybit/extension-kit/extbuild.ExtensionName=${NAME}' \ -X 'github.com/steadybit/extension-kit/extbuild.Version=${VERSION}' \ @@ -29,7 +30,7 @@ RUN make licenses-report ## ## Runtime ## -FROM alpine:3.16 +FROM alpine:3.18 LABEL "steadybit.com.discovery-disabled"="true"