From 4436d1f4287415789681ca1914bd52fc42f1def4 Mon Sep 17 00:00:00 2001 From: pratikbin Date: Mon, 19 Sep 2022 14:18:40 +0200 Subject: [PATCH] dockerfile: move TARGET* args for fast workflow & ... - Single COPY step for go mod and sum - Use ENV GOOS & GOARCH from TARGET* args --- Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c559ff90..ee0b9357e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,24 +2,21 @@ FROM --platform=$BUILDPLATFORM golang:1.18-alpine as BUILD WORKDIR /relayer -ARG TARGETARCH -ARG TARGETOS - # Update and install needed deps prioir to installing the binary. RUN apk update && \ - apk --no-cache add make git build-base + apk --no-cache add make git build-base # Copy go.mod and go.sum first and download for caching go modules -COPY go.mod go.mod -COPY go.sum go.sum +COPY go.mod go.sum ./ RUN go mod download # Copy the files from host COPY . . -RUN export GOOS=${TARGETOS} GOARCH=${TARGETARCH} && \ - make install +ARG TARGETARCH TARGETOS +ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH} +RUN make install FROM alpine:latest