Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build from source + with Go 1.21 + multi-arch #313

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
Dockerfile
Makefile
*.md
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15 as build
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as build

# Create appuser.
# See https://stackoverflow.com/a/55757473/12429735
Expand All @@ -14,16 +14,19 @@ RUN adduser \
"${USER}"

RUN apt-get update && apt-get install -y ca-certificates
RUN go get github.com/rakyll/hey

# Build
WORKDIR /go/src/github.com/rakyll/hey
COPY go.* ./
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/hey hey.go
COPY . .
ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH \
CGO_ENABLED=0 go build -o /go/bin/hey hey.go

###############################################################################
# final stage
FROM scratch
FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /etc/group /etc/group
Expand Down