Skip to content

Commit

Permalink
Build operator with rules_docker instead of containerfile
Browse files Browse the repository at this point in the history
We cannot push the operator image with recent images of Ubuntu in GitHub
actions because recent versions of Docker create the image differently
and as a result, they cannot be pushed to quay.io. Thus, replacing the
way we build the operator image to match how other images are built and
this way, we are able to push the image to quay.io.

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Jun 21, 2024
1 parent d13e5c1 commit b2efe21
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ build --strategy_regexp="RunAndCommitLayer ca-certificate-from-secret-layer.tar"

# For populator images, we need to use processwrapper sandbox as well
build --strategy_regexp="RunAndCommitLayer cmd/ovirt-populator/ovirt-imageio-layer-run-layer.tar"=processwrapper-sandbox

build --strategy_regexp="RunAndCommitLayer operator/forklift-operator-image-layer-run-layer.tar"=processwrapper-sandbox
13 changes: 7 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ load(
"@io_bazel_rules_docker//toolchains/docker:toolchain.bzl",
docker_toolchain_configure = "toolchain_configure",
)
load("@io_bazel_rules_docker//contrib:dockerfile_build.bzl", "dockerfile_image")

dockerfile_image(
name = "forklift-operator-image-containerfile",
dockerfile = "//operator:Containerfile",
)

docker_toolchain_configure(
name = "docker_config",
Expand Down Expand Up @@ -3345,6 +3339,13 @@ container_pull(
tag = "latest",
)

container_pull(
name = "ansible-operator",
registry = "quay.io",
repository = "operator-framework/ansible-operator",
tag = "main",
)

container_pull(
name = "opm-image",
# v1.43.1
Expand Down
28 changes: 27 additions & 1 deletion operator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image",
)
load("@io_bazel_rules_docker//docker/util:run.bzl", "container_run_and_commit_layer")

genrule(
name = "kustomize_bin",
Expand All @@ -13,9 +14,34 @@ genrule(
# OPERATOR
# 1. Build the oprator image with ansible dependencies and with roles.

container_image(
name = "forklift-operator-base-image",
base = "@ansible-operator//image",
directory = "/opt/ansible",
files = [
"requirements.yml",
"roles",
"watches.yaml",
],
)

container_run_and_commit_layer(
name = "forklift-operator-image-layer-run",
commands = [
"ansible-galaxy collection install -r /opt/ansible/requirements.yml && chmod -R ug+rwx /opt/ansible/.ansible",
],
docker_run_flags = ["--entrypoint=''"],
image = ":forklift-operator-base-image.tar",
)

container_image(
name = "forklift-operator-image",
base = "@forklift-operator-image-containerfile//image:dockerfile_image.tar",
base = ":forklift-operator-base-image",
directory = "/opt/ansible",
layers = [
":forklift-operator-image-layer-run",
],
user = "1001",
visibility = ["//visibility:public"],
)

Expand Down
8 changes: 0 additions & 8 deletions operator/Containerfile

This file was deleted.

0 comments on commit b2efe21

Please sign in to comment.