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 Multi-Arch Images #286

Merged
merged 1 commit into from
Jan 17, 2023
Merged
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
18 changes: 17 additions & 1 deletion .ci/build
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fi
VERSION="$(cat "${VERSION_FILE}")"

# If no LOCAL_BUILD environment variable is set, we configure the `go build` command
# to build for linux/amd64, windows/386 and darwin/amd64 architectures and without CGO enablement.
# to build for linux/amd64, linux/arm64, darwin/amd64, darwin/arm64 and windows/386 architectures and without CGO enablement.
if [[ -z "$LOCAL_BUILD" ]]; then
echo "Building docforge ${BINARY_PATH}/rel/docforge-linux-amd64"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
Expand All @@ -55,6 +55,14 @@ if [[ -z "$LOCAL_BUILD" ]]; then
-ldflags "-w -X github.com/gardener/docforge/pkg/version.Version=${VERSION}" \
cmd/*.go

echo "Building docforge ${BINARY_PATH}/rel/docforge-linux-arm64"
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
-a \
-v \
-o "${BINARY_PATH}/rel/docforge-linux-arm64" \
-ldflags "-w -X github.com/gardener/docforge/pkg/version.Version=${VERSION}" \
cmd/*.go

echo "Building docforge ${BINARY_PATH}/rel/docforge-darwin-amd64"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
-a \
Expand All @@ -63,6 +71,14 @@ if [[ -z "$LOCAL_BUILD" ]]; then
-ldflags "-w -X github.com/gardener/docforge/pkg/version.Version=${VERSION}" \
cmd/*.go

echo "Building docforge ${BINARY_PATH}/rel/docforge-darwin-arm64"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build \
-a \
-v \
-o "${BINARY_PATH}/rel/docforge-darwin-arm64" \
-ldflags "-w -X github.com/gardener/docforge/pkg/version.Version=${VERSION}" \
cmd/*.go

echo "Building docforge ${BINARY_PATH}/rel/docforge-windows-386.exe"
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build \
-a \
Expand Down
4 changes: 4 additions & 0 deletions .ci/pipeline_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ docforge:
inject_effective_version: true
component_descriptor: ~
publish:
oci-builder: docker-buildx
platforms:
- linux/amd64
- linux/arm64
dockerimages:
docforge:
registry: "gcr-readwrite"
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

FROM gcr.io/distroless/static-debian11:nonroot

COPY bin/rel/docforge-linux-amd64 /docforge
ARG TARGETOS
ARG TARGETARCH

COPY bin/rel/docforge-${TARGETOS}-${TARGETARCH} /docforge

WORKDIR /

Expand Down