Skip to content
Open
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
35 changes: 30 additions & 5 deletions tests/e2e/setup/build-and-push-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,36 @@ build_and_push_operator_image() {
echo "Docker build flags: ${DOCKER_BUILD_FLAGS}"
echo "Using image base: ${HUB}/${IMAGE_BASE}:${TAG}"

BUILD_WITH_CONTAINER=0 \
DOCKER_BUILD_FLAGS=${DOCKER_BUILD_FLAGS} \
IMAGE=${HUB}/${IMAGE_BASE}:${TAG} \
TARGET_ARCH=${TARGET_ARCH} \
make docker-push
# If using Podman, we need to build the binary locally and then build the image using the local Dockerfile
# since Podman doesn't support BuildKit's multi-platform builds with local source context.
# For Docker, we keep the existing make target which handles both building the binary and pushing the image in one step.
if [[ "${CONTAINER_CLI:-docker}" == "podman" ]]; then
repo_root=$(cd "${WD}/../../.." || exit; pwd)

BUILD_WITH_CONTAINER=0 TARGET_OS=linux TARGET_ARCH=${TARGET_ARCH} \
make -C "${repo_root}" build

tmp_ctx=$(mktemp -d)
cp "${repo_root}/Dockerfile" "${tmp_ctx}/Dockerfile"
mkdir -p "${tmp_ctx}/out/linux_${TARGET_ARCH}"
cp "${repo_root}/out/linux_${TARGET_ARCH}/sail-operator" "${tmp_ctx}/out/linux_${TARGET_ARCH}/sail-operator"

docker build \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be podman build or does it not matter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ohh, the podman configuration that I have already mount docker in the podman socket and allow to execute docker command but it's running at the end podman. Let me check if the behaviour keeps the same (I don't think there is going to be any change)

${DOCKER_BUILD_FLAGS} \
--push \
--build-arg TARGETOS=linux \
--build-arg TARGETARCH=${TARGET_ARCH} \
-t "${HUB}/${IMAGE_BASE}:${TAG}" \
"${tmp_ctx}"

rm -rf "${tmp_ctx}"
else
BUILD_WITH_CONTAINER=0 \
DOCKER_BUILD_FLAGS=${DOCKER_BUILD_FLAGS} \
IMAGE=${HUB}/${IMAGE_BASE}:${TAG} \
TARGET_ARCH=${TARGET_ARCH} \
make docker-push
fi
}

# Main logic
Expand Down
Loading