diff --git a/.bazelrc b/.bazelrc index 6805b0c40..aab1559e8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 diff --git a/WORKSPACE b/WORKSPACE index 503dc80f7..f1eb34c7d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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", @@ -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 diff --git a/operator/BUILD.bazel b/operator/BUILD.bazel index 033907bc9..4bbd7565c 100644 --- a/operator/BUILD.bazel +++ b/operator/BUILD.bazel @@ -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", @@ -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"], ) diff --git a/operator/Containerfile b/operator/Containerfile deleted file mode 100644 index e1b1f5d68..000000000 --- a/operator/Containerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM quay.io/operator-framework/ansible-operator:main - -COPY requirements.yml ${HOME}/requirements.yml -COPY watches.yaml ${HOME}/watches.yaml -COPY roles ${HOME}/roles - -RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \ - && chmod -R ug+rwx ${HOME}/.ansible \ No newline at end of file