From 2fff68b0143b14fc1f6fccdccf3f3f6c69fc79e4 Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 18 Sep 2023 14:21:09 +0300 Subject: [PATCH 01/13] Modify the build.sh script to work with podman --- .github/workflows/build-pr-check.yml | 10 ++--- .github/workflows/next-build.yml | 10 ++--- build/build.sh | 63 +++++++++++++++------------- 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-pr-check.yml b/.github/workflows/build-pr-check.yml index d2eaf447d3..ea75d678bf 100644 --- a/.github/workflows/build-pr-check.yml +++ b/.github/workflows/build-pr-check.yml @@ -31,23 +31,23 @@ jobs: cache: 'maven' - name: Login to docker.io if: github.event_name == 'pull_request' - uses: docker/login-action@v2 + uses: redhat-actions/podman-login@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} registry: docker.io - name: Login to quay.io if: github.event_name == 'pull_request' - uses: docker/login-action@v2 + uses: redhat-actions/podman-login@v1 with: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} registry: quay.io - name: Build with Maven run: mvn -B clean install -U -Pintegration - - name: Build docker images + - name: Build images if: github.event_name == 'pull_request' run: ./build/build.sh --tag:${{ env.PR_IMAGE_TAG }} - - name: Push docker images + - name: Push images if: github.event_name == 'pull_request' - run: docker push quay.io/eclipse/che-server:${{ env.PR_IMAGE_TAG }} + run: podman push quay.io/eclipse/che-server:${{ env.PR_IMAGE_TAG }} diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index 2a6a464cc0..b95aa18644 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -29,28 +29,28 @@ jobs: java-version: '11' cache: 'maven' - name: Login to docker.io - uses: docker/login-action@v2 + uses: redhat-actions/podman-login@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} registry: docker.io - name: Login to quay.io - uses: docker/login-action@v2 + uses: redhat-actions/podman-login@v1 with: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} registry: quay.io - name: Build with Maven run: mvn -B clean install -U -Pintegration - - name: Build docker images + - name: Build images id: build run: | echo "short_sha1=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT ./build/build.sh --tag:next --sha-tag - name: Push docker images run: | - docker push quay.io/eclipse/che-server:next - docker push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }} + podman push quay.io/eclipse/che-server:next + podman push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }} - name: Create failure MM message if: ${{ failure() }} run: | diff --git a/build/build.sh b/build/build.sh index 63b872faac..9c9fbc9fe4 100755 --- a/build/build.sh +++ b/build/build.sh @@ -15,6 +15,7 @@ IMAGE_ALIASES=${IMAGE_ALIASES:-} ERROR=${ERROR:-} DIR=${DIR:-} SHA_TAG=${SHA_TAG:-} +BUILDER=${BUILDER:-} skip_tests() { if [ $SKIP_TESTS = "true" ]; then @@ -104,6 +105,36 @@ build() { DIR=$(cd "$(dirname "$0")"; pwd) fi + if [ -z $BUILDER ]; then + echo "BUILDER is not specified, trying with podman" + BUILDER=$(command -v podman || true) + if [[ ! -x $BUILDER ]]; then + echo "[WARNING] podman is not installed, trying with buildah" + BUILDER=$(command -v buildah || true) + if [[ ! -x $BUILDER ]]; then + echo "[WARNING] buildah is not installed, trying with docker" + BUILDER=$(command -v docker || true) + if [[ ! -x $BUILDER ]]; then + echo "[ERROR] neither docker, buildah, nor podman are installed. Aborting"; exit 1 + fi + else + BUILD_COMMAND="bud" + fi + fi + else + if [[ ! -x $(command -v "$BUILDER" || true) ]]; then + echo "Builder $BUILDER is missing. Aborting."; exit 1 + fi + if [[ $BUILDER =~ "docker" || $BUILDER =~ "podman" ]]; then + if [[ ! $($BUILDER ps) ]]; then + echo "Builder $BUILDER is not functioning. Aborting."; exit 1 + fi + fi + if [[ $BUILDER =~ "buildah" ]]; then + BUILD_COMMAND="bud" + fi + fi + # If Dockerfile is empty, build all Dockerfiles if [ -z ${DOCKERFILE} ]; then DOCKERFILES_TO_BUILD="$(ls ${DIR}/Dockerfile*)" @@ -138,14 +169,14 @@ build_image() { -e "s;\${BUILD_PREFIX};${PREFIX};" \ -e "s;\${BUILD_TAG};${TAG};" \ > ${DIR}/.Dockerfile - cd "${DIR}" && docker build -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . + cd "${DIR}" && "${BUILDER}" build -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . DOCKER_BUILD_STATUS=$? rm ${DIR}/.Dockerfile if [ $DOCKER_BUILD_STATUS -eq 0 ]; then printf "Build of ${BLUE}${IMAGE_NAME} ${GREEN}[OK]${NC}\n" if [ ! -z "${SHA_TAG}" ]; then SHA_IMAGE_NAME=${ORGANIZATION}/${PREFIX}-${NAME}:${SHA_TAG} - docker tag ${IMAGE_NAME} ${SHA_IMAGE_NAME} + "${BUILDER}" tag ${IMAGE_NAME} ${SHA_IMAGE_NAME} DOCKER_TAG_STATUS=$? if [ $DOCKER_TAG_STATUS -eq 0 ]; then printf "Re-tagging with SHA based tag ${BLUE}${SHA_IMAGE_NAME} ${GREEN}[OK]${NC}\n" @@ -157,7 +188,7 @@ build_image() { if [ ! -z "${IMAGE_ALIASES}" ]; then for TMP_IMAGE_NAME in ${IMAGE_ALIASES} do - docker tag ${IMAGE_NAME} ${TMP_IMAGE_NAME}:${TAG} + "${BUILDER}" tag ${IMAGE_NAME} ${TMP_IMAGE_NAME}:${TAG} DOCKER_TAG_STATUS=$? if [ $DOCKER_TAG_STATUS -eq 0 ]; then printf " /alias ${BLUE}${TMP_IMAGE_NAME}:${TAG}${NC} ${GREEN}[OK]${NC}\n" @@ -175,32 +206,6 @@ build_image() { fi } -check_docker() { - if ! docker ps > /dev/null 2>&1; then - output=$(docker ps) - printf "${RED}Docker not installed properly: ${output}${NC}\n" - exit 1 - fi -} - -docker_exec() { - if has_docker_for_windows_client; then - MSYS_NO_PATHCONV=1 docker.exe "$@" - else - "$(which docker)" "$@" - fi -} - -has_docker_for_windows_client() { - GLOBAL_HOST_ARCH=$(docker version --format {{.Client}}) - - if [[ "${GLOBAL_HOST_ARCH}" = *"windows"* ]]; then - return 0 - else - return 1 - fi -} - get_full_path() { echo "$(cd "$(dirname "${1}")"; pwd)/$(basename "$1")" } From 9f52db9e73f3444620f091f86dd03f9fa99ea5a9 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 27 Sep 2023 11:14:34 +0300 Subject: [PATCH 02/13] update dockerfile --- devfile.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index 79a7b2509a..ca60c0bb37 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -13,9 +13,9 @@ components: - name: m2 volume: {} commands: - - id: build + - id: buildsources exec: - label: "1. Build" + label: "1. Build sources" component: tools workingDir: ${PROJECT_SOURCE} commandLine: | @@ -23,3 +23,13 @@ commands: group: kind: build isDefault: true + - id: buildimage + exec: + label: "2. Build image" + component: tools + workingDir: ${PROJECT_SOURCE} + commandLine: | + ./build/build.sh + group: + kind: build + isDefault: true From ab13ebbc38b0efc81d7810b86c5139b71ec6726b Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:42:20 +0300 Subject: [PATCH 03/13] Update dockerfiles/build.include Co-authored-by: Nick Boldt --- build/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.sh b/build/build.sh index 9c9fbc9fe4..3562534ee0 100755 --- a/build/build.sh +++ b/build/build.sh @@ -115,7 +115,7 @@ build() { echo "[WARNING] buildah is not installed, trying with docker" BUILDER=$(command -v docker || true) if [[ ! -x $BUILDER ]]; then - echo "[ERROR] neither docker, buildah, nor podman are installed. Aborting"; exit 1 + echo "[ERROR] This script requires podman, buildah or docker to be installed. Must abort!"; exit 1 fi else BUILD_COMMAND="bud" From 22d58bf1c7bf05dd4bd6867de4436451d3cfdbe0 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:43:18 +0300 Subject: [PATCH 04/13] Update devfile.yaml Co-authored-by: Nick Boldt --- devfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devfile.yaml b/devfile.yaml index ca60c0bb37..9171a43bae 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -19,7 +19,7 @@ commands: component: tools workingDir: ${PROJECT_SOURCE} commandLine: | - mvn clean install -DskipTests + mvn clean install -V -e -Pfast -DskipTests -Dskip-validate-sources -Denforcer.skip=true group: kind: build isDefault: true From 2cbc797731b37e055de8760430afd791a2476bf3 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:44:08 +0300 Subject: [PATCH 05/13] Update .github/workflows/next-build.yml Co-authored-by: Nick Boldt --- .github/workflows/next-build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index b95aa18644..8e6b7dd96f 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -49,6 +49,13 @@ jobs: ./build/build.sh --tag:next --sha-tag - name: Push docker images run: | + + podman push quay.io/eclipse/che-keycloak:next + podman push quay.io/eclipse/che-keycloak:${{ steps.build.outputs.short_sha1 }} + + podman push quay.io/eclipse/che-postgres:next + podman push quay.io/eclipse/che-postgres:${{ steps.build.outputs.short_sha1 }} + podman push quay.io/eclipse/che-server:next podman push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }} - name: Create failure MM message From 51b18badbc7c59cecaab3c00ded41547c7959e98 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:44:21 +0300 Subject: [PATCH 06/13] Update .github/workflows/next-build.yml Co-authored-by: Nick Boldt --- .github/workflows/next-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index 8e6b7dd96f..e9e362d3b3 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -50,7 +50,6 @@ jobs: - name: Push docker images run: | - podman push quay.io/eclipse/che-keycloak:next podman push quay.io/eclipse/che-keycloak:${{ steps.build.outputs.short_sha1 }} podman push quay.io/eclipse/che-postgres:next From 2590f1ed8d4528bfb216eaaa2c01562df5a421ce Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:44:28 +0300 Subject: [PATCH 07/13] Update .github/workflows/next-build.yml Co-authored-by: Nick Boldt --- .github/workflows/next-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index e9e362d3b3..2d6b970160 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -50,7 +50,6 @@ jobs: - name: Push docker images run: | - podman push quay.io/eclipse/che-keycloak:${{ steps.build.outputs.short_sha1 }} podman push quay.io/eclipse/che-postgres:next podman push quay.io/eclipse/che-postgres:${{ steps.build.outputs.short_sha1 }} From 161cff2cced33a0ca52e720004ead3d95fc34ad1 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:44:40 +0300 Subject: [PATCH 08/13] Update .github/workflows/next-build.yml Co-authored-by: Nick Boldt --- .github/workflows/next-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index 2d6b970160..2b9ad4ae72 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -51,7 +51,6 @@ jobs: run: | - podman push quay.io/eclipse/che-postgres:next podman push quay.io/eclipse/che-postgres:${{ steps.build.outputs.short_sha1 }} podman push quay.io/eclipse/che-server:next From 0ac80b530491f745f0630ac4ab33f7c80e61cb78 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:44:50 +0300 Subject: [PATCH 09/13] Update .github/workflows/next-build.yml Co-authored-by: Nick Boldt --- .github/workflows/next-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index 2b9ad4ae72..971c4ecf10 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -51,7 +51,6 @@ jobs: run: | - podman push quay.io/eclipse/che-postgres:${{ steps.build.outputs.short_sha1 }} podman push quay.io/eclipse/che-server:next podman push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }} From b7f4ae7730fbf36b3574e14a5c776d9257035516 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:53:37 +0300 Subject: [PATCH 10/13] Update dockerfiles/build.include Co-authored-by: Nick Boldt --- build/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build/build.sh b/build/build.sh index 3562534ee0..b2bd42bcce 100755 --- a/build/build.sh +++ b/build/build.sh @@ -105,6 +105,7 @@ build() { DIR=$(cd "$(dirname "$0")"; pwd) fi + BUILD_COMAMAND="build" if [ -z $BUILDER ]; then echo "BUILDER is not specified, trying with podman" BUILDER=$(command -v podman || true) From 7e76e50bea82a33f677b3899b09933cae90517b3 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 3 Oct 2023 10:53:49 +0300 Subject: [PATCH 11/13] Update dockerfiles/build.include Co-authored-by: Nick Boldt --- build/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.sh b/build/build.sh index b2bd42bcce..d0bb7d0e6d 100755 --- a/build/build.sh +++ b/build/build.sh @@ -170,7 +170,7 @@ build_image() { -e "s;\${BUILD_PREFIX};${PREFIX};" \ -e "s;\${BUILD_TAG};${TAG};" \ > ${DIR}/.Dockerfile - cd "${DIR}" && "${BUILDER}" build -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . + cd "${DIR}" && "${BUILDER}" "${BUILD_COMMAND}" -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . DOCKER_BUILD_STATUS=$? rm ${DIR}/.Dockerfile if [ $DOCKER_BUILD_STATUS -eq 0 ]; then From 411a572357eeac7c8acf1f006668e9c6bcc35f02 Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 3 Oct 2023 10:56:26 +0300 Subject: [PATCH 12/13] fixup --- build/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build/build.sh b/build/build.sh index d0bb7d0e6d..261b61f711 100755 --- a/build/build.sh +++ b/build/build.sh @@ -50,6 +50,7 @@ init() { ARGS="" OPTIONS="" DOCKERFILE="" + BUILD_COMMAND="build" BUILD_ARGS="" while [ $# -gt 0 ]; do From db903cf6fcadeb754f28146129af798abf5da771 Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Thu, 19 Oct 2023 17:55:07 +0300 Subject: [PATCH 13/13] Update .github/workflows/next-build.yml --- .github/workflows/next-build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/next-build.yml b/.github/workflows/next-build.yml index 971c4ecf10..b95aa18644 100644 --- a/.github/workflows/next-build.yml +++ b/.github/workflows/next-build.yml @@ -49,9 +49,6 @@ jobs: ./build/build.sh --tag:next --sha-tag - name: Push docker images run: | - - - podman push quay.io/eclipse/che-server:next podman push quay.io/eclipse/che-server:${{ steps.build.outputs.short_sha1 }} - name: Create failure MM message