From 9b7687ef2b1534f86c8718e0505946071df35883 Mon Sep 17 00:00:00 2001 From: odidev Date: Thu, 22 Apr 2021 10:47:06 +0000 Subject: [PATCH] Release images for ARM64 Signed-off-by: odidev --- .../build-publish-next-multiarch.yml | 35 +++++++++++++++++++ .github/workflows/build-publish-next.yml | 1 + .github/workflows/happy-path-tests.yaml | 1 + .github/workflows/pr.yml | 6 ++++ dockerfiles/build.include | 8 +++-- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-publish-next-multiarch.yml diff --git a/.github/workflows/build-publish-next-multiarch.yml b/.github/workflows/build-publish-next-multiarch.yml new file mode 100644 index 000000000..2ca242993 --- /dev/null +++ b/.github/workflows/build-publish-next-multiarch.yml @@ -0,0 +1,35 @@ +name: Build & Publish `multiarch next image` + +on: + push: + branches: + - master + +jobs: + build_mutiarch_image: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + name: Checkout che-theia source code + - uses: actions/setup-node@v1 + name: Configuring nodejs 12.x version + with: + node-version: '12.x' + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + version: latest + - name: Login to docker.io + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + registry: docker.io + - name: Build and publish images + run: | + docker image prune -a -f + ./build.sh --root-yarn-opts:--ignore-scripts --dockerfile:Dockerfile.alpine + env: + CDN_PREFIX: https://static.developers.redhat.com/che/theia_artifacts/ + MONACO_CDN_PREFIX: https://cdn.jsdelivr.net/npm/ + DOCKER_TARGET_PLATFORM: multiarch diff --git a/.github/workflows/build-publish-next.yml b/.github/workflows/build-publish-next.yml index 038f373c8..e1038455e 100644 --- a/.github/workflows/build-publish-next.yml +++ b/.github/workflows/build-publish-next.yml @@ -43,6 +43,7 @@ jobs: env: CDN_PREFIX: https://static.developers.redhat.com/che/theia_artifacts/ MONACO_CDN_PREFIX: https://cdn.jsdelivr.net/npm/ + DOCKER_TARGET_PLATFORM: linux/amd64 - name: Set-up npmjs auth token run: printf "//registry.npmjs.org/:_authToken=${{ secrets.CHE_NPM_AUTH_TOKEN }}\n" >> ~/.npmrc - name: Publish packages to npmjs diff --git a/.github/workflows/happy-path-tests.yaml b/.github/workflows/happy-path-tests.yaml index efc8e8fd3..944bed5a4 100644 --- a/.github/workflows/happy-path-tests.yaml +++ b/.github/workflows/happy-path-tests.yaml @@ -23,6 +23,7 @@ jobs: chectlchannel: [ 'next', 'stable' ] env: JOB_NAME_SUFFIX: ${{matrix.dist}} ${{matrix.chectlchannel}} + DOCKER_TARGET_PLATFORM: linux/amd64 runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dff8dad6e..dcf1d31f7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,6 +19,8 @@ jobs: linelint: runs-on: ubuntu-20.04 name: eof-newline + env: + DOCKER_TARGET_PLATFORM: linux/amd64 steps: - name: Checkout uses: actions/checkout@v2 @@ -27,6 +29,8 @@ jobs: id: linelint node-build: runs-on: ubuntu-20.04 + env: + DOCKER_TARGET_PLATFORM: linux/amd64 steps: - uses: actions/checkout@v2 name: Checkout che-theia source code @@ -45,6 +49,8 @@ jobs: matrix: dist: [ 'alpine', 'ubi8' ] runs-on: ubuntu-20.04 + env: + DOCKER_TARGET_PLATFORM: linux/amd64 steps: - uses: actions/checkout@v2 name: Checkout che-theia source code diff --git a/dockerfiles/build.include b/dockerfiles/build.include index 0bd4482de..13c7cb359 100755 --- a/dockerfiles/build.include +++ b/dockerfiles/build.include @@ -218,10 +218,14 @@ build_image() { done if ! dry_run; then - cd "${DIR}" && docker build --cache-from ${IMAGE_NAME} -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} ${DOCKER_BUILD_TARGET} . + if [ "$DOCKER_TARGET_PLATFORM" == "multiarch" ]; then + cd "${DIR}" && docker buildx build --push --platform linux/arm64,linux/amd64 --cache-from ${IMAGE_NAME} -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} ${DOCKER_BUILD_TARGET} . + else + cd "${DIR}" && docker build --cache-from ${IMAGE_NAME} -f ${DIR}/.Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} ${DOCKER_BUILD_TARGET} . + fi rm ${DIR}/.Dockerfile fi - + if [ $? -eq 0 ]; then printf "Build of ${BLUE}${IMAGE_NAME} ${GREEN}[OK]${NC}\n" if [ ! -z "${IMAGE_ALIASES}" ]; then