diff --git a/.github/workflows/build-pr-check.yml b/.github/workflows/build-pr-check.yml index ea75d678bf..8fa0f46300 100644 --- a/.github/workflows/build-pr-check.yml +++ b/.github/workflows/build-pr-check.yml @@ -29,6 +29,8 @@ jobs: distribution: 'temurin' java-version: '11' cache: 'maven' + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Login to docker.io if: github.event_name == 'pull_request' uses: redhat-actions/podman-login@v1 @@ -45,9 +47,6 @@ jobs: registry: quay.io - name: Build with Maven run: mvn -B clean install -U -Pintegration - - name: Build images + - name: Build and push images if: github.event_name == 'pull_request' - run: ./build/build.sh --tag:${{ env.PR_IMAGE_TAG }} - - name: Push images - if: github.event_name == 'pull_request' - run: podman push quay.io/eclipse/che-server:${{ env.PR_IMAGE_TAG }} + run: ./build/build.sh --tag:${{ env.PR_IMAGE_TAG }} --build-platforms:linux/amd64,linux/ppc64le,linux/arm64 --builder:podman --push-image diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index b95aa18644..2b0c9be364 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -28,6 +28,10 @@ jobs: distribution: 'temurin' java-version: '11' cache: 'maven' + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to docker.io uses: redhat-actions/podman-login@v1 with: @@ -46,7 +50,7 @@ jobs: id: build run: | echo "short_sha1=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - ./build/build.sh --tag:next --sha-tag + ./build/build.sh --tag:next --sha-tag --build-platforms:linux/amd64,linux/ppc64le,linux/arm64 - name: Push docker images run: | podman push quay.io/eclipse/che-server:next diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4508e269f1..b3a49971e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,6 +62,10 @@ jobs: echo "cannot create release, when tag already exists" exit 1 fi + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to docker.io uses: docker/login-action@v2 with: diff --git a/build/build.sh b/build/build.sh index 261b61f711..6790115843 100755 --- a/build/build.sh +++ b/build/build.sh @@ -45,6 +45,7 @@ init() { ORGANIZATION="quay.io/eclipse" PREFIX="che" TAG="next" + PUSH_IMAGE=false SKIP_TESTS=false NAME="che" ARGS="" @@ -52,6 +53,7 @@ init() { DOCKERFILE="" BUILD_COMMAND="build" BUILD_ARGS="" + BUILD_PLATFORMS="" while [ $# -gt 0 ]; do case $1 in @@ -79,6 +81,9 @@ init() { --skip-tests) SKIP_TESTS=true shift ;; + --push-image) + PUSH_IMAGE=true + shift ;; --sha-tag) SHA_TAG=$(git rev-parse --short HEAD) shift ;; @@ -89,6 +94,12 @@ init() { BUILD_ARGS_CSV="${1#*:}" prepare_build_args $BUILD_ARGS_CSV shift ;; + --build-platforms:*) + BUILD_PLATFORMS="${1#*:}" + shift ;; + --builder:*) + BUILDER="${1#*:}" + shift ;; --*) printf "${RED}Unknown parameter: $1${NC}\n"; exit 2 ;; *) @@ -171,11 +182,35 @@ build_image() { -e "s;\${BUILD_PREFIX};${PREFIX};" \ -e "s;\${BUILD_TAG};${TAG};" \ > ${DIR}/.Dockerfile - cd "${DIR}" && "${BUILDER}" "${BUILD_COMMAND}" -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . + cd "${DIR}" + + if [[ -n $BUILD_PLATFORMS ]]; then + if [[ $BUILDER == "podman" ]]; then + "${BUILDER}" manifest create ${IMAGE_NAME} + "${BUILDER}" "${BUILD_COMMAND}" --platform ${BUILD_PLATFORMS} -f ${DIR}/.Dockerfile --manifest ${IMAGE_NAME} ${BUILD_ARGS} . + else + printf "${RED}Multi-platform image building is only supported for podman builder${NC}\n" + exit 1 + fi + else + "${BUILDER}" "${BUILD_COMMAND}" -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . + fi + DOCKER_BUILD_STATUS=$? rm ${DIR}/.Dockerfile if [ $DOCKER_BUILD_STATUS -eq 0 ]; then printf "Build of ${BLUE}${IMAGE_NAME} ${GREEN}[OK]${NC}\n" + + if [[ $PUSH_IMAGE == "true" ]]; then + printf "Push image ${BLUE}${IMAGE_NAME} ${NC}\n" + if [[ -n $BUILD_PLATFORMS ]] && [[ $BUILDER == "podman" ]]; then + ${BUILDER} manifest push ${IMAGE_NAME} docker://{IMAGE_NAME} + else + ${BUILDER} push ${IMAGE_NAME} + fi + printf "Push of ${BLUE}${IMAGE_NAME} ${GREEN}[OK]${NC}\n" + fi + if [ ! -z "${SHA_TAG}" ]; then SHA_IMAGE_NAME=${ORGANIZATION}/${PREFIX}-${NAME}:${SHA_TAG} "${BUILDER}" tag ${IMAGE_NAME} ${SHA_IMAGE_NAME} diff --git a/make-release.sh b/make-release.sh index 572dbfeffe..1513252add 100755 --- a/make-release.sh +++ b/make-release.sh @@ -7,6 +7,7 @@ REGISTRY="quay.io" ORGANIZATION="eclipse" IMAGE="quay.io/eclipse/che-server" +BUILD_PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" sed_in_place() { SHORT_UNAME=$(uname -s) @@ -275,7 +276,7 @@ buildImages() { fi # BUILD IMAGES - bash "$(pwd)/che-server/build/build.sh" --tag:${TAG} + bash "$(pwd)/che-server/build/build.sh" --tag:${TAG} --build-platforms:${BUILD_PLATFORMS} if [[ $? -ne 0 ]]; then echo "ERROR:" echo "build of che-server image $TAG is failed!"