Skip to content

Commit

Permalink
Full podman builds, removed uses of Docker
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Cho <[email protected]>
  • Loading branch information
jcho02 committed Sep 19, 2023
1 parent 2ed24e3 commit bad0772
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 57 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/build-and-publish.yaml

This file was deleted.

28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,16 @@ build:

.PHONY: operator-image
operator-image: generate
docker buildx build --push --platform linux/amd64,linux/ppc64le -f build/Dockerfile -t $(OPERATOR_IMG) .
$(CONTAINER_RUNTIME) build -f build/Dockerfile --no-cache --platform linux/amd64 -t $(OPERATOR_IMG)-amd64 --build-arg TAGRTEARCH=amd64 .
$(CONTAINER_RUNTIME) build -f build/Dockerfile --no-cache --platform linux/ppc64le -t $(OPERATOR_IMG)-ppc64le --build-arg TARGETARCH=ppc64le .
$(CONTAINER_RUNTIME) push ${OPERATOR_IMG}-amd64
$(CONTAINER_RUNTIME) push ${OPERATOR_IMG}-ppc64le
$(CONTAINER_RUNTIME) manifest create $(OPERATOR_IMG)
$(CONTAINER_RUNTIME) manifest add $(OPERATOR_IMG) $(OPERATOR_IMG)-amd64 $(OPERATOR_IMG)-ppc64le

.PHONY: operator-push
operator-push:
$(CONTAINER_RUNTIME) push $(PUSH_OPTIONS) ${OPERATOR_IMG}
$(CONTAINER_RUNTIME) manifest push --all $(PUSH_OPTIONS) ${OPERATOR_IMG}

.PHONY: osd-e2e-test-image
osd-e2e-test-image: tools
Expand Down Expand Up @@ -199,11 +204,16 @@ bundle: $(KUSTOMIZE) $(OPERATOR_SDK) generate

.PHONY: bundle-image
bundle-image: bundle ## Build the bundle image.
$(CONTAINER_RUNTIME) build --platform linux/amd64,linux/ppc64le -f bundle.Dockerfile -t $(BUNDLE_IMG) .
$(CONTAINER_RUNTIME) build --no-cache -f bundle.Dockerfile --platform linux/amd64 -t $(BUNDLE_IMG)-amd64 .
$(CONTAINER_RUNTIME) build --no-cache -f bundle.Dockerfile --platform linux/ppc64le -t $(BUNDLE_IMG)-ppc64le .
$(CONTAINER_RUNTIME) push $(BUNDLE_IMG)-amd64
$(CONTAINER_RUNTIME) push $(BUNDLE_IMG)-ppc64le
$(CONTAINER_RUNTIME) manifest create $(BUNDLE_IMG)
$(CONTAINER_RUNTIME) manifest add $(BUNDLE_IMG) $(BUNDLE_IMG)-amd64 $(BUNDLE_IMG)-ppc64le

.PHONY: bundle-push
bundle-push: ## Build the bundle image.
$(CONTAINER_RUNTIME) push $(PUSH_OPTIONS) $(BUNDLE_IMG)
$(CONTAINER_RUNTIME) manifest push --all $(PUSH_OPTIONS) $(BUNDLE_IMG)

# The image tag given to the resulting catalog image
CATALOG_IMG_BASE ?= $(IMAGE_BASE)-catalog
Expand All @@ -217,13 +227,13 @@ CATALOG_IMG_LATEST ?= $(IMAGE_BASE)-catalog:latest
# operator package manager tool, 'opm'.
.PHONY: catalog-image
catalog-image: $(OPM)
$(OPM) render $(BUNDLE_IMG) \
--output=yaml >> olm/observability-operator-index/index.yaml
./olm/update-channels.sh $(CHANNELS) $(OPERATOR_BUNDLE)
$(OPM) validate ./olm/observability-operator-index
$(OPM) render quay.io/jcho0/observability-operator-catalog:0.0.23 \
--output=yaml >> hack/olm/index.yaml
#./olm/update-channels.sh $(CHANNELS) $(OPERATOR_BUNDLE)
$(OPM) validate .hack/olm/observability-operator-catalog

$(CONTAINER_RUNTIME) build \
-f olm/observability-operator-index.Dockerfile \
-f hack/olm/observability-operator-index.Dockerfile \
-t $(CATALOG_IMG)

# tag the catalog img:version as latest so that continious release
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.20 as builder

ARG TARGETOS TARGETARCH
ARG TARGETARCH
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand All @@ -15,7 +15,7 @@ COPY cmd/operator/main.go cmd/operator/main.go
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -o manager cmd/operator/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -a -o manager cmd/operator/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
22 changes: 10 additions & 12 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,45 +51,44 @@ digest() {

build_push_operator_image() {
make operator-image OPERATOR_IMG=${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}:${TAG}
make operator-push OPERATOR_IMG=${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}:${TAG}
digest "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}:${TAG}" OPERATOR_DIGEST
# need exporting so that yq can see them
export OPERATOR_DIGEST
declare -r OPERATOR_DIGEST
}

prepare_operator_files() {
# prepare operator files, then build and push operator bundle and catalog
# index images.

yq eval -i '
/usr/local/bin/yq eval -i '
.metadata.name = strenv(OPERATOR_NAME) |
.metadata.annotations.version = strenv(TAG) |
.metadata.annotations.containerImage = strenv(OPERATOR_DIGEST) |
.metadata.labels += {"operatorframework.io/arch.amd64": "supported", "operatorframework.io/arch.ppc64le": "supported", "operatorframework.io/os.linux": "supported"} |
del(.spec.replaces) |
.spec.install.spec.deployments[0].name = strenv(OPERATOR_NAME) |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].image = strenv(OPERATOR_DIGEST)
.spec.install.spec.deployments[2].spec.template.spec.containers[0].image = strenv(OPERATOR_DIGEST)
' "${CSV_PATH}"

yq eval -i '
/usr/local/bin/yq eval -i '
.annotations."operators.operatorframework.io.bundle.channel.default.v1" = "test" |
.annotations."operators.operatorframework.io.bundle.channels.v1" = "test"
' "${ANNOTATIONS_PATH}"
}

build_bundle_image() {
make bundle-image BUNDLE_IMG=${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}:${TAG}
make bundle-image BUNDLE_IMG=${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle:${TAG}
make bundle-push BUNDLE_IMG=${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle:${TAG}
}

bundle_digests() {
build_single_arch_index_image() {
AMD64_DIGEST=$(skopeo inspect --raw docker://${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle:${TAG} | \
jq -r '.manifests[] | select(.platform.architecture == "amd64" and .platform.os == "linux").digest')
POWER_DIGEST=$(skopeo inspect --raw docker://${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle:${TAG} | \
jq -r '.manifests[] | select(.platform.architecture == "ppc64le" and .platform.os == "linux").digest')
}

build_single_arch_index_image() {
opm index add --build-tool podman --bundles "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle@${AMD64_DIGEST}" --tag "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-catalog:${TAG}-amd64" --binary-image "quay.io/operator-framework/opm:v1.28.0-amd64"
opm index add --build-tool podman --bundles "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle@${POWER_DIGEST}" --tag "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-catalog:${TAG}-ppc64le" --binary-image "quay.io/operator-framework/opm:v1.28.0-ppc64le"
/usr/local/bin/opm index add --build-tool podman --bundles "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle@${AMD64_DIGEST}" --tag "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-catalog:${TAG}-amd64" --binary-image "quay.io/operator-framework/opm:v1.28.0-amd64"
/usr/local/bin/opm index add --build-tool podman --bundles "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-bundle@${POWER_DIGEST}" --tag "${REGISTRY}/${NAMESPACE}/${OPERATOR_NAME}-catalog:${TAG}-ppc64le" --binary-image "quay.io/operator-framework/opm:v1.28.0-ppc64le"
}

push_single_arch_index_images() {
Expand All @@ -112,7 +111,6 @@ main() {
build_push_operator_image
prepare_operator_files
build_bundle_image
bundle_digests
build_single_arch_index_image
push_single_arch_index_images
build_catalog_manifest
Expand Down

0 comments on commit bad0772

Please sign in to comment.