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

Use ubi instead of golang image for main Dockerbuild #548

Merged
merged 4 commits into from
Oct 25, 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
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Build the manager binary
FROM golang:1.20 as builder
FROM registry.access.redhat.com/ubi8-minimal:latest as builder
ARG GO_PLATFORM=amd64
ARG GO_VERSION_ARG
ENV PATH=$PATH:/usr/local/go/bin
RUN microdnf install tar gzip

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

RUN if [ -z "${GO_VERSION_ARG}" ]; then \
GO_VERSION=$(grep '^go [0-9]\+.[0-9]\+' go.mod | cut -d ' ' -f 2); \
else \
GO_VERSION=${GO_VERSION_ARG}; \
fi; \
rm -rf /usr/local/go; \
curl -L --output - "https://golang.org/dl/go${GO_VERSION}.linux-${GO_PLATFORM}.tar.gz" | tar -xz -C /usr/local/

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
Expand Down Expand Up @@ -54,3 +67,4 @@ COPY --from=builder /workspace/manager .
USER ${USER_ID}:${GROUP_ID}

ENTRYPOINT ["/manager"]

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ docker-login:

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
$(CONTAINER_COMMAND) build -t ${IMG} .
ARCH=$(shell go env GOARCH) && $(CONTAINER_COMMAND) build -t ${IMG} . --build-arg GO_PLATFORM=$${ARCH}

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand Down