From bad5d3f67ab409c47201912e81b6677e3ffa2aef Mon Sep 17 00:00:00 2001 From: Socheat Sok Date: Sun, 23 Jun 2024 17:12:37 +0700 Subject: [PATCH] Optimize docker build --- Dockerfile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 04763ab..6f3a3c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,28 @@ ARG GO_VERSION ARG ALPINE_VERSION +# buildkit +ARG TARGETOS="linux" +ARG TARGETARCH="amd64" ARG BUILDPLATFORM="linux/amd64" -ARG GO_SOCKADDR_VERSION="master" -FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder RUN apk add --no-cache git make -ARG GO_SOCKADDR_VERSION -ADD https://github.com/hashicorp/go-discover.git#${GO_SOCKADDR_VERSION} /hashicorp/go-discover -RUN <