Skip to content

Commit

Permalink
Merge pull request #3 from kashalls/buildx-dockerfile
Browse files Browse the repository at this point in the history
Buildx automatically provides envs for us to use.
  • Loading branch information
kashalls authored Dec 15, 2023
2 parents 12d1107 + 67e89f4 commit 710d504
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
FROM golang:1.21.5-alpine as build
WORKDIR /go/src/github.com/kashalls/kromgo

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT=""

ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
GOARM=${TARGETVARIANT}

# Download Go modules
COPY go.mod go.sum ./
RUN go mod download
Expand All @@ -10,7 +20,7 @@ RUN go mod download
COPY *.go ./

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /kromgo
RUN go build -ldflags="-s -w" -o /kromgo

FROM scratch
COPY --from=build /kromgo /kromgo/
Expand Down

0 comments on commit 710d504

Please sign in to comment.