Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-arch build using Buildx #633

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .one-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ compliance-checks:
containerize:
dind: true
abort_on_failure: true
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.12
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.24
script: |
#!/usr/bin/env bash
echo $STAGE
Expand Down
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Build the manager binary
FROM registry.access.redhat.com/ubi8-minimal:latest as builder

ARG GO_PLATFORM=amd64
ARG TARGETARCH
ARG GO_VERSION_ARG
ENV PATH=$PATH:/usr/local/go/bin
RUN microdnf install tar gzip
Expand All @@ -11,12 +11,18 @@ WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum

RUN if [ -z "${GO_VERSION_ARG}" ]; then \
RUN if [ -z "${TARGETARCH}" ]; then \
GO_PLATFORM=amd64; \
else \
GO_PLATFORM="${TARGETARCH}"; \
fi; \
if [ -z "${GO_VERSION_ARG}" ]; then \
GO_VERSION=$(grep '^go [0-9]\+.[0-9]\+' go.mod | cut -d ' ' -f 2); \
else \
GO_VERSION=${GO_VERSION_ARG}; \
fi; \
rm -rf /usr/local/go; \
echo "https://golang.org/dl/go${GO_VERSION}.linux-${GO_PLATFORM}.tar.gz"; \
curl -L --output - "https://golang.org/dl/go${GO_VERSION}.linux-${GO_PLATFORM}.tar.gz" | tar -xz -C /usr/local/

# cache deps before building and copying source so that we don't need to re-download as much
Expand Down
33 changes: 3 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,47 +303,23 @@ rm -rf $$TMP_DIR ;\
}
endef

.PHONY: opm
OPM = ./bin/opm
opm: ## Download opm locally if necessary.
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif

# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
# 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 $(SKIP_TLS_VERIFY) --container-tool $(CONTAINER_COMMAND) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) --permissive

kind-e2e-test:
./operators/scripts/test/e2e-kind.sh --test-tag "${BUILD_NUMBER}"

build-manifest:
./operators/scripts/build/build-manifest.sh --registry "${PUBLISH_REGISTRY}" --image "${OPERATOR_IMAGE}" --tag "${RELEASE_TARGET}"

build-operator-pipeline:
./operators/scripts/build/build-operator.sh --registry "${REGISTRY}" --image "${PIPELINE_OPERATOR_IMAGE}" --tag "${RELEASE_TARGET}" --go-version "${GO_VERSION}"
./operators/scripts/build/build-operator.sh --registry "${REGISTRY}" --image "${PIPELINE_OPERATOR_IMAGE}" --tag "${RELEASE_TARGET}" --go-version "${GO_VERSION}" --arch "${ARCH}" --enable-buildx "${ENABLE_BUILDX}"

build-manifest-pipeline:
./operators/scripts/build/build-manifest.sh --registry "${REGISTRY}" --image "${IMAGE}" --tag "${RELEASE_TARGET}"

build-bundle-pipeline:
./operators/scripts/build/build-bundle.sh --prod-image "${PIPELINE_PRODUCTION_IMAGE}" --registry "${REGISTRY}" --image "${PIPELINE_OPERATOR_IMAGE}" --tag "${RELEASE_TARGET}"

build-catalog-pipeline: opm ## Build a catalog image.
./operators/scripts/build/build-catalog.sh -n "v${OPM_VERSION}" -b "${REDHAT_BASE_IMAGE}" -o "${OPM}" --container-tool "docker" -r "${REGISTRY}" -i "${PIPELINE_OPERATOR_IMAGE}-bundle:${RELEASE_TARGET}" -p "${PIPELINE_PRODUCTION_IMAGE}-bundle" -a "${PIPELINE_OPERATOR_IMAGE}-catalog:${RELEASE_TARGET}" -t "${PWD}/operator-build" -v "${VERSION}"
build-catalog-pipeline:
./operators/scripts/build/build-catalog.sh --prod-image "${OPERATOR_IMAGE}" --registry "${REGISTRY}" --image "${PIPELINE_OPERATOR_IMAGE}" --tag "${RELEASE_TARGET}" --version "${VERSION}" --arch "{ARCH}" --enable-buildx "${ENABLE_BUILDX}"

test-e2e:
./scripts/e2e-release.sh --registry-name default-route --registry-namespace openshift-image-registry \
Expand All @@ -360,9 +336,6 @@ bundle-build-podman:
bundle-push-podman:
podman push --format=docker "${BUNDLE_IMG}"

build-catalog:
opm index add --bundles "${BUNDLE_IMG}" --tag "${CATALOG_IMG}"

push-catalog: docker-login
podman push --format=docker "${CATALOG_IMG}"

Expand Down
53 changes: 53 additions & 0 deletions catalog.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM registry.redhat.io/openshift4/ose-operator-registry:v4.14 AS builder
FROM registry.redhat.io/ubi8/ubi-minimal

# Add label for location of Declarative Config root directory & required OpenShift labels
ARG VERSION_LABEL=1.3.1
ARG RELEASE_LABEL=XX
ARG VCS_REF=0123456789012345678901234567890123456789
ARG VCS_URL="https://github.com/WASdev/websphere-liberty-operator"
ARG NAME="websphere-liberty-operator-catalog"
ARG SUMMARY="WebSphere Liberty Operator Catalog"
ARG DESCRIPTION="This image contains the catalog for WebSphere Liberty Operator."

# Set DC-specific label for the location of the DC root directory in the image
LABEL operators.operatorframework.io.index.configs.v1=/configs \
name=$NAME \
vendor=IBM \
version=$VERSION_LABEL \
release=$RELEASE_LABEL \
description=$DESCRIPTION \
summary=$SUMMARY \
io.k8s.display-name=$SUMMARY \
io.k8s.description=$DESCRIPTION \
vcs-type=git \
vcs-ref=$VCS_REF \
vcs-url=$VCS_URL \
url=$VCS_URL

## Copy Apache license
COPY LICENSE /licenses

USER root

# Pick up any latest fixes
RUN microdnf update && microdnf clean all

# Copy required tooling, licenses, and declarative config into defined location
COPY --from=builder /bin/opm /bin/opm
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe

# Note: the COPY directive can also point to a directory structure and it will recurse thru the directory structure and use any yaml/json files it locates
COPY catalog /configs

# Validate catalog file
RUN ["/bin/opm", "validate", "/configs"]

EXPOSE 50051

USER 1001

WORKDIR /tmp
ENTRYPOINT ["/bin/opm"]
CMD ["serve", "/configs", "--cache-dir=/tmp/cache"]
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]
1 change: 0 additions & 1 deletion ebcDockerBuilderWLO.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ properties([
string(name: 'command', defaultValue: "make build-operator-pipeline REGISTRY=cp.stg.icr.io", description: 'Build command to execute on target arch machine, e.g. make build-pipeline-releases'),
string(name: 'PIPELINE_OPERATOR_IMAGE', defaultValue: "cp/websphere-liberty-operator", description: 'namespace to push image to in registry'),
string(name: 'RELEASE_TARGET', defaultValue: "main", description: 'release branch to use'),
string(name: 'OPM_VERSION', defaultValue: "4.12", description: 'Redhat CLI OPM version'),
string(name: 'PIPELINE_PRODUCTION_IMAGE', defaultValue: "icr.io/cpopen/websphere-liberty-operator", description: 'namespace in prod registry'),
string(name: 'REDHAT_BASE_IMAGE', defaultValue: "registry.redhat.io/openshift4/ose-operator-registry", description: 'base image for operator'),
string(name: 'REDHAT_REGISTRY', defaultValue: "registry.redhat.io", description: 'RH registry used for docker login'),
Expand Down
43 changes: 0 additions & 43 deletions index.Dockerfile

This file was deleted.