Skip to content

Commit

Permalink
dockerfile: move TARGET* args for fast workflow & ... (#993)
Browse files Browse the repository at this point in the history
- Single COPY step for go mod and sum
- Use ENV GOOS & GOARCH from TARGET* args

Co-authored-by: pratikbin <pratikbin+010101@no-reply-git.luolix.top>
  • Loading branch information
2 people authored and agouin committed Nov 15, 2022
1 parent b6553be commit b9e0da6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b9e0da6

Please sign in to comment.