Skip to content

Commit

Permalink
chore: use podman as container engine
Browse files Browse the repository at this point in the history
Signed-off-by: Sunil Thaha <sthaha@redhat.com>
  • Loading branch information
sthaha committed Mar 27, 2024
1 parent 2cd68dc commit a8e4a85
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.21 as builder
FROM docker.io/library/golang:1.21 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
44 changes: 22 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ cluster-restart: ## restart the local development cluster
CLUSTER_PROVIDER=$(CLUSTER_PROVIDER) \
VERSION=$(LOCAL_DEV_CLUSTER_VERSION) \
GRAFANA_ENABLE=$(GRAFANA_ENABLE) \
KIND_WORKER_NODES=$(KIND_WORKER_NODES) \
./hack/cluster.sh restart
KIND_WORKER_NODES=$(KIND_WORKER_NODES) \

.PHONY: cluster-down
cluster-down: ## delete the local development cluster
Expand All @@ -164,10 +164,10 @@ run: install fmt vet ## Run a controller from your host against openshift cluste
$(RUN_ARGS) \
2>&1 | tee tmp/operator.log

# docker_tag accepts an image:tag and a list of additional tags comma-separated
# podman_tag accepts an image:tag and a list of additional tags comma-separated
# it tags the image with the additional tags
# E.g. given foo:bar, a,b,c, it will tag foo:bar as foo:a, foo:b, foo:c
define docker_tag
define podman_tag
@{ \
set -eu ;\
img="$(1)" ;\
Expand All @@ -176,52 +176,52 @@ define docker_tag
\
img_path=$${img%:*} ;\
for tag in $$(echo $$tags | tr -s , ' ' ); do \
docker tag $$img $$img_path:$$tag ;\
podman tag $$img $$img_path:$$tag ;\
done \
}
endef


# docker_push accepts an image:tag and a list of additional tags comma-separated
# podman_push accepts an image:tag and a list of additional tags comma-separated
# it push the image:tag all other images with the additional tags
# E.g. given foo:bar, a,b,c, it will push foo:bar, foo:a, foo:b, foo:c
define docker_push
define podman_push
@{ \
set -eu ;\
img="$(1)" ;\
tags="$(2)" ;\
echo "docker push $$img and additional tags: '$$tags'" ;\
echo "podman push $$img and additional tags: '$$tags'" ;\
\
img_path=$${img%:*} ;\
docker push $$img ;\
podman push $$img ;\
for tag in $$(echo $$tags | tr -s , ' ' ); do \
docker push $$img_path:$$tag ;\
podman push $$img_path:$$tag ;\
done \
}
endef


# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# (i.e. podman build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.podman.com/develop/develop-images/build_enhancements/
.PHONY: operator-build
operator-build: manifests generate test ## Build docker image with the manager.
operator-build: manifests generate test ## Build podman image with the manager.
go mod tidy
docker build -t $(OPERATOR_IMG) \
podman build -t $(OPERATOR_IMG) \
--build-arg TARGETOS=$(GOOS) \
--build-arg TARGETARCH=$(GOARCH) \
--platform=linux/$(GOARCH) .
$(call docker_tag,$(OPERATOR_IMG),$(ADDITIONAL_TAGS))
$(call podman_tag,$(OPERATOR_IMG),$(ADDITIONAL_TAGS))


.PHONY: operator-push
operator-push: ## Push docker image with the manager.
$(call docker_push,$(OPERATOR_IMG),$(ADDITIONAL_TAGS))
operator-push: ## Push podman image with the manager.
$(call podman_push,$(OPERATOR_IMG),$(ADDITIONAL_TAGS))


.PHONY: e2e-test-image
e2e-test-image: test
docker build -f tests/Dockerfile \
podman build -f tests/Dockerfile \
--platform=linux/$(GOARCH) \
-t $(E2E_TEST_IMG) .

Expand Down Expand Up @@ -346,14 +346,14 @@ bundle: generate manifests kustomize operator-sdk ## Generate bundle manifests a

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
docker build -f bundle.Dockerfile \
podman build -f bundle.Dockerfile \
-t $(BUNDLE_IMG) \
--platform=linux/$(GOARCH) .
$(call docker_tag,$(BUNDLE_IMG),$(ADDITIONAL_TAGS))
$(call podman_tag,$(BUNDLE_IMG),$(ADDITIONAL_TAGS))

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
$(call docker_push,$(BUNDLE_IMG),$(ADDITIONAL_TAGS))
$(call podman_push,$(BUNDLE_IMG),$(ADDITIONAL_TAGS))

.PHONY: create-bundle
create-bundle:
Expand Down Expand Up @@ -395,9 +395,9 @@ endif
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
$(OPM) index add --container-tool podman --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
docker push $(CATALOG_IMG)
podman push $(CATALOG_IMG)
1 change: 1 addition & 0 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ main() {
export CLUSTER_PROVIDER
export GRAFANA_ENABLE
export KIND_WORKER_NODES
export CTR_CMD=podman
cd "$DEV_CLUSTER_DIR"
"$DEV_CLUSTER_DIR/main.sh" "$op"

Expand Down
16 changes: 8 additions & 8 deletions tests/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ update_crds() {
kind_load_image() {
local img="$1"

run docker pull "$img"
run podman pull "$img"
run kind load docker-image "$img"
$CI_MODE && run docker image rm "$img"
$CI_MODE && run podman image rm "$img"
return 0
}

Expand All @@ -347,19 +347,19 @@ kind_load_images() {
return 0
}

docker_prune() {
header "Prune Docker"
run docker system prune -a -f
podman_prune() {
header "Prune Images and Volumes"
run podman system prune -a -f
}

deploy_operator() {
header "Build and Deploy Operator"

$CI_MODE && {
# NOTE: ci runs out of disk space at times, hence run images
info "pruning docker images and volumes"
run docker images
docker_prune
info "pruning container images and volumes"
run podman images
podman_prune
run df -h
}

Expand Down

0 comments on commit a8e4a85

Please sign in to comment.