Skip to content

Commit

Permalink
Speed up crossplatform Docker image building
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed May 8, 2022
1 parent 1159391 commit 7cb18b9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# docker build -t msoap/shell2http .

# build image
FROM golang:alpine as go_builder
FROM --platform=$BUILDPLATFORM golang:alpine as go_builder

RUN apk add --no-cache git

ADD . $GOPATH/src/github.com/msoap/shell2http
WORKDIR $GOPATH/src/github.com/msoap/shell2http

ENV CGO_ENABLED=0
# GOARM=6 affects only "arm" builds
ENV GOARM=6
# "amd64", "arm64" or "arm" (--platform=linux/amd64,linux/arm64,linux/arm/v6)
ENV GOARCH=$TARGETARCH
ENV GOOS=linux

RUN go build -v -trimpath -ldflags="-w -s -X 'main.version=$(git describe --abbrev=0 --tags | sed s/v//)'" -o /go/bin/shell2http .

# final image
Expand Down

0 comments on commit 7cb18b9

Please sign in to comment.