Add build args

args: operating system (OS) and architecture (ARCH)
This commit is contained in:
Sidd Shah 2020-04-03 23:45:49 -04:00
parent 045639e0ee
commit 70b98b603b

View file

@ -1,5 +1,8 @@
FROM golang:alpine as builder FROM golang:alpine as builder
ARG OS
ARG ARCH
WORKDIR /go/src/github.com/eko/pihole-exporter WORKDIR /go/src/github.com/eko/pihole-exporter
COPY . . COPY . .
@ -7,7 +10,7 @@ RUN apk update && \
apk --no-cache add git alpine-sdk upx apk --no-cache add git alpine-sdk upx
RUN GO111MODULE=on go mod vendor RUN GO111MODULE=on go mod vendor
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o binary ./ RUN CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH go build -ldflags '-s -w' -o binary ./
RUN upx -f --brute binary RUN upx -f --brute binary
FROM scratch FROM scratch