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

Fixes issue with arm64 support. #404

Merged
merged 3 commits into from
Jan 16, 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: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Build the manager binary
ARG ARCH="amd64"
FROM golang:1.17 as builder
ARG BUILDOS
ARG BUILDPLATFORM
ARG BUILDARCH
ARG BUILDVARIANT
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -17,11 +24,16 @@ COPY controllers/ controllers/
COPY k8sutils/ k8sutils/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on go build -a -o manager main.go
ARG LDFLAGS="-s -w"
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ENV CGO_ENABLED=0

RUN GO111MODULE=on go build -ldflags "${LDFLAGS}" -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot-${ARCH}
FROM gcr.io/distroless/static:nonroot
LABEL maintainer="The Opstree Opensource <[email protected]>"
WORKDIR /
COPY --from=builder /workspace/manager .
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ vet:
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

docker-create:
docker buildx create --platform "linux/amd64,linux/arm64" --use

# Build the docker image
docker-build:
docker build -t ${IMG} .
docker buildx build --platform="linux/arm64,linux/amd64" -t ${IMG} .

# Push the docker image
docker-push:
Expand Down Expand Up @@ -116,4 +119,4 @@ bundle: manifests kustomize
# Build the bundle image.
.PHONY: bundle-build
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
docker buildx build --platform="linux/arm64,linux/amd64" -f bundle.Dockerfile -t $(BUNDLE_IMG) .