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

Chore: CRW-4043 Improve process for building midstream and syncing to downstream #1638

Open
wants to merge 5 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
4 changes: 2 additions & 2 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v3
- name: Build image
run: docker build .
run: docker build -f build/dockerfiles/Dockerfile .
multiplatform-image-build:
runs-on: ubuntu-22.04
steps:
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Build images
uses: docker/build-push-action@v3
with:
file: Dockerfile
file: build/dockerfiles/Dockerfile
platforms: linux/amd64,linux/ppc64le
tags: quay.io/eclipse/che-operator:next
source-code-validation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Build operator image
uses: docker/build-push-action@v3
with:
file: Dockerfile
file: build/dockerfiles/Dockerfile
platforms: linux/amd64,linux/ppc64le
push: true
tags: quay.io/eclipse/che-operator:next
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ debug: install-che-operands genenerate-env ## Run and debug Eclipse Che operator

docker-build: ## Build Eclipse Che operator image
if [ "$(SKIP_TESTS)" = true ]; then
${IMAGE_TOOL} build -t ${IMG} --build-arg SKIP_TESTS=true .
${IMAGE_TOOL} build -t ${IMG} --build-arg SKIP_TESTS=true -f build/dockerfiles/Dockerfile .
else
${IMAGE_TOOL} build -t ${IMG} .
${IMAGE_TOOL} build -t ${IMG} -f build/dockerfiles/Dockerfile .
fi

docker-push: ## Push Eclipse Che operator image to a registry
Expand All @@ -159,7 +159,7 @@ update-dev-resources: validate-requirements ## Update development resources
echo "[INFO] UBI8 image $${UBI8_MINIMAL_IMAGE}"

# Dockerfile
sed -i 's|registry.access.redhat.com/ubi8-minimal:[^\s]* |'$${UBI8_MINIMAL_IMAGE}' |g' $(PROJECT_DIR)/Dockerfile
sed -i 's|registry.access.redhat.com/ubi8-minimal:[^\s]* |'$${UBI8_MINIMAL_IMAGE}' |g' $(PROJECT_DIR)/build/dockerfiles/Dockerfile

$(MAKE) bundle CHANNEL=next
$(MAKE) gen-deployment
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions build/dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Dockerfile Clarification

**Dockerfile** is the Eclipse Che Operator build file, used in this repo to publish to [quay.io/eclipse/che-operator](https://quay.io/repository/eclipse/che-operator?tab=tags).

See also [community-operators/eclipse-che](https://github.com/redhat-openshift-ecosystem/community-operators-prod/tree/main/operators/eclipse-che).

**brew.Dockerfile** is a variation on `Dockerfile` specifically for Red Hat builds, and cannot be run locally as is. It is used to publish the [Red Hat OpenShift Dev Spaces Operator](https://github.com/redhat-developer/devspaces-images/tree/devspaces-3-rhel-8/devspaces-operator) image to [quay.io/devspaces/devspaces-rhel8-operator](https://quay.io/repository/devspaces/devspaces-rhel8-operator?tab=tags).
SDawley marked this conversation as resolved.
Show resolved Hide resolved

See also [Red Hat OpenShift Dev Spaces Operator Bundle](https://github.com/redhat-developer/devspaces-images/tree/devspaces-3-rhel-8/devspaces-operator-bundle).
57 changes: 57 additions & 0 deletions build/dockerfiles/brew.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright (c) 2019-2023 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

# https://registry.access.redhat.com/rhel8/go-toolset
FROM rhel8/go-toolset:1.18.9-13 as builder
ENV GOPATH=/go/
ARG SKIP_TESTS="false"
USER root

# cachito:gomod step 1: copy cachito sources where we can use them; source env vars; set working dir
COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR
RUN source $REMOTE_SOURCES_DIR/devspaces-images-operator/cachito.env
WORKDIR $REMOTE_SOURCES_DIR/devspaces-images-operator/app/devspaces-operator

RUN mkdir -p /tmp/devworkspace-operator/templates/ && \
mv $REMOTE_SOURCES_DIR/DEV_WORKSPACE_CONTROLLER/app/deploy/deployment/* /tmp/devworkspace-operator/templates/

RUN mkdir -p /tmp/header-rewrite-traefik-plugin && \
mv $REMOTE_SOURCES_DIR/DEV_HEADER_REWRITE_TRAEFIK_PLUGIN/app/headerRewrite.go /tmp/header-rewrite-traefik-plugin && \
mv $REMOTE_SOURCES_DIR/DEV_HEADER_REWRITE_TRAEFIK_PLUGIN/app/.traefik.yml /tmp/header-rewrite-traefik-plugin

# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum

# Copy the go source
COPY main.go main.go
COPY vendor/ vendor/
COPY mocks/ mocks/
COPY api/ api/
COPY config/ config/
COPY controllers/ controllers/
COPY pkg/ pkg/

# build operator
RUN export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH="amd64"; elif [[ ${ARCH} == "aarch64" ]]; then export ARCH="arm64"; fi && \
if [[ ${SKIP_TESTS} == "false" ]]; then export MOCK_API=true && go test -mod=vendor -v ./...; fi && \
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on go build -mod=vendor -a -o che-operator main.go

# https://registry.access.redhat.com/ubi8-minimal
FROM ubi8-minimal:8.7-1085

COPY --from=builder /tmp/devworkspace-operator/templates /tmp/devworkspace-operator/templates
COPY --from=builder /tmp/header-rewrite-traefik-plugin /tmp/header-rewrite-traefik-plugin
COPY --from=builder $REMOTE_SOURCES_DIR/devspaces-images-operator/app/devspaces-operator/che-operator /manager

ENTRYPOINT ["/manager"]

# append Brew metadata here
2 changes: 1 addition & 1 deletion build/scripts/minikube-tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ collectClusterScopeResources() {
}

buildAndCopyCheOperatorImageToMinikube() {
docker build -t "${OPERATOR_IMAGE}" -f Dockerfile --build-arg SKIP_TESTS=true .
docker build -t "${OPERATOR_IMAGE}" -f build/dockerfiles/Dockerfile --build-arg SKIP_TESTS=true .
docker save "${OPERATOR_IMAGE}" > /tmp/operator.tar
eval $(minikube docker-env) && docker load -i /tmp/operator.tar && rm /tmp/operator.tar
}
Expand Down
1 change: 1 addition & 0 deletions build/scripts/olm/test-catalog-from-sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ buildOperatorFromSources() {
oc delete buildconfigs ${REGISTRY_OPERATOR_IMAGE_NAME} --ignore-not-found=true -n "${NAMESPACE}"
oc delete imagestreamtag ${REGISTRY_OPERATOR_IMAGE_NAME}:latest --ignore-not-found=true -n "${NAMESPACE}"

cp ${OPERATOR_REPO}/build/dockerfiles/Dockerfile ${OPERATOR_REPO}
oc new-build --binary --strategy docker --name "${REGISTRY_OPERATOR_IMAGE_NAME}" -n "${NAMESPACE}"
oc start-build "${REGISTRY_OPERATOR_IMAGE_NAME}" --from-dir "${OPERATOR_REPO}" -n "${NAMESPACE}" --wait
}
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/release/make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ releaseOperatorCode() {
docker login quay.io -u "${QUAY_ECLIPSE_CHE_USERNAME}" -p "${QUAY_ECLIPSE_CHE_PASSWORD}"

echo "[INFO] releaseOperatorCode :: Build operator image in platforms: $BUILDX_PLATFORMS"
docker buildx build --platform "$BUILDX_PLATFORMS" --push -t "quay.io/eclipse/che-operator:${RELEASE}" .
docker buildx build --platform "$BUILDX_PLATFORMS" --push -t "quay.io/eclipse/che-operator:${RELEASE}" -f build/dockerfiles/Dockerfile .
}

replaceImagesTags() {
Expand Down