Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Oct 17, 2024
1 parent 157a605 commit 6c1a49b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build-pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
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
if: github.event_name == 'pull_request'
uses: redhat-actions/podman-login@v1
Expand All @@ -49,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 }} --build-platforms:linux/amd64,linux/ppc64le,linux/arm64
- 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
38 changes: 32 additions & 6 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ init() {
ORGANIZATION="quay.io/eclipse"
PREFIX="che"
TAG="next"
PUSH_IMAGE=false
SKIP_TESTS=false
NAME="che"
ARGS=""
Expand All @@ -53,7 +54,6 @@ init() {
BUILD_COMMAND="build"
BUILD_ARGS=""
BUILD_PLATFORMS=""
BUILD_PLATFORMS_ARG=""

while [ $# -gt 0 ]; do
case $1 in
Expand Down Expand Up @@ -81,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 ;;
Expand All @@ -94,6 +97,9 @@ init() {
--build-platforms:*)
BUILD_PLATFORMS="${1#*:}"
shift ;;
--builder:*)
BUILDER="${1#*:}"
shift ;;
--*)
printf "${RED}Unknown parameter: $1${NC}\n"; exit 2 ;;
*)
Expand Down Expand Up @@ -142,10 +148,6 @@ build() {
fi
fi

if [ ! -z $BUILD_PLATFORMS ]; then
BUILD_PLATFORMS_ARG="--platform ${BUILD_PLATFORMS}"
fi

# If Dockerfile is empty, build all Dockerfiles
if [ -z ${DOCKERFILE} ]; then
DOCKERFILES_TO_BUILD="$(ls ${DIR}/Dockerfile*)"
Expand Down Expand Up @@ -180,11 +182,35 @@ build_image() {
-e "s;\${BUILD_PREFIX};${PREFIX};" \
-e "s;\${BUILD_TAG};${TAG};" \
> ${DIR}/.Dockerfile
cd "${DIR}" && "${BUILDER}" "${BUILD_COMMAND}" ${BUILD_PLATFORMS_ARG} -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}
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}
Expand Down

0 comments on commit 6c1a49b

Please sign in to comment.