Skip to content

Commit

Permalink
feat: Build server image for different platforms
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Oct 16, 2024
1 parent 1824619 commit 6260010
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/next-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ init() {
DOCKERFILE=""
BUILD_COMMAND="build"
BUILD_ARGS=""
BUILD_PLATFORMS=""
BUILD_PLATFORMS_ARG=""

while [ $# -gt 0 ]; do
case $1 in
Expand Down Expand Up @@ -89,6 +91,9 @@ init() {
BUILD_ARGS_CSV="${1#*:}"
prepare_build_args $BUILD_ARGS_CSV
shift ;;
--build-platforms*:*)
BUILD_PLATFORMS="${1#*:}"
shift ;;
--*)
printf "${RED}Unknown parameter: $1${NC}\n"; exit 2 ;;
*)
Expand Down Expand Up @@ -137,6 +142,10 @@ 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 @@ -171,7 +180,7 @@ 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}" && "${BUILDER}" "${BUILD_COMMAND}" ${PLATFORMS_ARG} -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} .
DOCKER_BUILD_STATUS=$?
rm ${DIR}/.Dockerfile
if [ $DOCKER_BUILD_STATUS -eq 0 ]; then
Expand Down
3 changes: 2 additions & 1 deletion make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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!"
Expand Down

0 comments on commit 6260010

Please sign in to comment.