-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5070ea0
commit bad5d3f
Showing
1 changed file
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
ARG GO_VERSION | ||
ARG ALPINE_VERSION | ||
|
||
# buildkit | ||
ARG TARGETOS="linux" | ||
ARG TARGETARCH="amd64" | ||
ARG BUILDPLATFORM="linux/amd64" | ||
ARG GO_SOCKADDR_VERSION="master" | ||
|
||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder | ||
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder | ||
RUN apk add --no-cache git make | ||
ARG GO_SOCKADDR_VERSION | ||
ADD https://github.com/hashicorp/go-discover.git#${GO_SOCKADDR_VERSION} /hashicorp/go-discover | ||
RUN <<EOT | ||
ARG GO_SOCKADDR_VERSION="master" | ||
ADD https://github.com/hashicorp/go-discover.git#${GO_SOCKADDR_VERSION} /tmp/source | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
<<EOT | ||
set -ex | ||
cd /hashicorp/go-discover/cmd/discover | ||
go build -o /discover | ||
cd /tmp/source/cmd/discover | ||
export CGO_ENABLED=0 | ||
export GOOS=linux | ||
for GOARCH in amd64 arm64; do | ||
export GOARCH | ||
go build -o /discover-$GOOS-$GOARCH | ||
done | ||
EOT | ||
|
||
FROM scratch | ||
COPY --from=builder /hashicorp/go-discover/cmd/discover /discover | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
COPY --from=builder /discover-$TARGETOS-$TARGETARCH /discover |