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

ROX-24040: Set Podman instead of Docker to fix RHEL8 builders #1917

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ WORKDIR /src
RUN go env -w GOCACHE=/go/.cache; \
go env -w GOMODCACHE=/go/pkg/mod

# We previously used --mount=type=bind in the next RUN command
# (see https://docs.docker.com/build/guide/mounts/#add-bind-mounts)
# but this did not work with SELinux volumes and Docker, as only
# Podman supports the relabel=shared option
# (see https://docs.podman.io/en/v4.4/markdown/options/mount.html).
# This adds a layer but works with Docker and Podman.
COPY go.mod go.sum ./

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x

COPY . ./
Expand Down
22 changes: 7 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ else
GOBIN=$(shell $(GO) env GOBIN)
endif

ifeq ($(IMAGE_PLATFORM),)
Copy link
Contributor

@kovayur kovayur Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break multi-arch builds.

  1. We build arm images on Github actions
  2. We can build x86 images for openshift internal registry (image/push/internal) on arm based machines

IMAGE_PLATFORM=linux/$(shell $(GO) env GOARCH)
endif

ifeq ($(CLUSTER_DNS),)
# This makes sure that the "ingresscontroller" kind, which only exists on OpenShift by default, is only queried
# when CLUSTER_DNS is not set.
Expand Down Expand Up @@ -497,12 +493,12 @@ docker/login: docker/login/fleet-manager
.PHONY: docker/login

docker/login/fleet-manager:
@docker logout quay.io
$(DOCKER) logout quay.io || true # Swallog podman error if not logged in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: How about renaming DOCKER to CONTAINER_ENGINE ?

@DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) login -u "${QUAY_USER}" --password-stdin <<< "${QUAY_TOKEN}" quay.io
.PHONY: docker/login/fleet-manager

docker/login/probe:
@docker logout quay.io
$(DOCKER) logout quay.io || true # Swallow podman error if not logged in
@DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) login -u "${QUAY_PROBE_USER}" --password-stdin <<< "${QUAY_PROBE_TOKEN}" quay.io
.PHONY: docker/login/probe

Expand All @@ -513,7 +509,8 @@ docker/login/internal:

# Build the image
image/build:
DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) buildx build -t $(SHORT_IMAGE_REF) . --load
DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) build -t $(SHORT_IMAGE_REF) .
DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) tag $(IMAGE_REF) $(SHORT_IMAGE_REF)
@echo "New image tag: $(SHORT_IMAGE_REF). You might want to"
@echo "export FLEET_MANAGER_IMAGE=$(SHORT_IMAGE_REF)"
ifeq ("$(CLUSTER_TYPE)","kind")
Expand Down Expand Up @@ -557,16 +554,11 @@ image/push/emailsender: image/build/emailsender
@echo "emailsender image was pushed as $(IMAGE_REF)."
.PHONY: image/push/emailsender

# Build and push the image
image/push: image/push/fleet-manager image/push/probe
.PHONY: image/push

image/push/fleet-manager: IMAGE_REF="$(external_image_registry)/$(image_repository):$(image_tag)"
image/push/fleet-manager:
DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) buildx build -t $(IMAGE_REF) --platform $(IMAGE_PLATFORM) --push .
image/push/fleet-manager: image/build
DOCKER_CONFIG=${DOCKER_CONFIG} $(DOCKER) push $(IMAGE_REF)
@echo
@echo "Image was pushed as $(IMAGE_REF). You might want to"
@echo "export FLEET_MANAGER_IMAGE=$(IMAGE_REF)"
@echo "Image was pushed as $(IMAGE_REF)."
.PHONY: image/push/fleet-manager

image/push/probe: IMAGE_REF="$(external_image_registry)/$(probe_image_repository):$(image_tag)"
Expand Down
6 changes: 6 additions & 0 deletions build_push_app_interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ source ./scripts/build_setup.sh
# Push the image:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment for the lines 47, 57:
Do we need remove this for podman or use an alternative?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which lines /flags you mean, can you please specify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOCKER_CONFIG=${DOCKER_CONFIG}
We used it only on app-interface and I'm happy to get rid of it.
I don't think it makes any difference to podman.

echo "Quay.io user and token is set, will push images to $IMAGE_REPOSITORY"
make \
DOCKER=podman \
DOCKER_CONFIG="${DOCKER_CONFIG}" \
QUAY_USER="${QUAY_USER}" \
QUAY_TOKEN="${QUAY_TOKEN}" \
Expand All @@ -51,6 +52,7 @@ make \
image/push/fleet-manager

make \
DOCKER=podman \
DOCKER_CONFIG="${DOCKER_CONFIG}" \
QUAY_USER="${QUAY_USER}" \
QUAY_TOKEN="${QUAY_TOKEN}" \
Expand All @@ -62,6 +64,7 @@ make \
image/push/fleet-manager

make \
DOCKER=podman \
DOCKER_CONFIG="${DOCKER_CONFIG}" \
QUAY_PROBE_USER="${QUAY_USER}" \
QUAY_PROBE_TOKEN="${QUAY_TOKEN}" \
Expand All @@ -72,6 +75,7 @@ make \
image/push/probe

make \
DOCKER=podman \
DOCKER_CONFIG="${DOCKER_CONFIG}" \
QUAY_PROBE_USER="${QUAY_USER}" \
QUAY_PROBE_TOKEN="${QUAY_TOKEN}" \
Expand All @@ -83,6 +87,7 @@ make \
image/push/probe

make \
DOCKER=podman \
DOCKER_CONFIG="${DOCKER_CONFIG}" \
QUAY_USER="${QUAY_USER}" \
QUAY_TOKEN="${QUAY_TOKEN}" \
Expand All @@ -93,6 +98,7 @@ make \
image/push/emailsender

make \
DOCKER=podman \
DOCKER_CONFIG="${DOCKER_CONFIG}" \
QUAY_USER="${QUAY_USER}" \
QUAY_TOKEN="${QUAY_TOKEN}" \
Expand Down
Loading