diff --git a/.github/workflows/pushimage-next.yaml b/.github/workflows/pushimage-next.yaml index 3d6a91821..681ac7739 100644 --- a/.github/workflows/pushimage-next.yaml +++ b/.github/workflows/pushimage-next.yaml @@ -17,78 +17,20 @@ name: Next Dockerimage on: push: - branches: [main] + branches: [main, feat/multi-arch-support] repository_dispatch: types: [build] jobs: - indexServerBuild: - runs-on: ubuntu-latest - steps: - - name: Check out registry support source code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - name: Setup Go environment - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 - with: - go-version: 1.19 - - name: Login to Quay - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - - name: Build the index server base image - run: | - cd index/server - export GOPATH=$(go env GOPATH) - go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 - bash ./build.sh - - name: Push the index server base image - run: cd index/server && bash ./push.sh quay.io/devfile/devfile-index-base:next - - dispatch: - needs: indexServerBuild - strategy: - matrix: - repo: ['devfile/registry'] - runs-on: ubuntu-latest - steps: - - name: Get the repository name and commit sha - id: get_commit_info - run: | - # Check if repository name is not set in the client payload - # If it's not set, the triggered commit came from this repo (registry-support) - # If it is set, the triggered commit came from registry-viewer - if [ -z ${{ github.event.client_payload.repo }} ]; - then - echo ::set-output name=repo::$(echo ${{ github.event.repository.name }}) - else - echo ::set-output name=repo::$(echo ${{ github.event.client_payload.repo }}) - fi - - # Check if commit sha is not set in the client payload - # If it's not set, the triggered commit came from this repo (registry-support) - # If it is set, the triggered commit came from registry-viewer - - if [ -z ${{ github.event.client_payload.sha }} ]; - then - echo ::set-output name=sha::$(echo ${{ github.sha }}) - else - echo ::set-output name=sha::$(echo ${{ github.event.client_payload.sha }}) - fi - - name: Repository dispatch - uses: peter-evans/repository-dispatch@v1 - with: - token: ${{ secrets.REPO_ACCESS_TOKEN }} - repository: ${{ matrix.repo }} - event-type: build - client-payload: '{"repo": "${{ steps.get_commit_info.outputs.REPO }}", "sha": "${{ steps.get_commit_info.outputs.SHA }}"}' - ociRegistryBuild: runs-on: ubuntu-latest steps: - name: Check out registry support source code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Build and push oci-registry docker image uses: docker/build-push-action@v1.1.0 with: @@ -96,23 +38,102 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} registry: quay.io - repository: devfile/oci-registry + repository: rh-ee-jdubrick/test-oci-registry dockerfile: ./oci-registry/Dockerfile + platforms: linux/amd64,linux/arm64 tags: next tag_with_sha: true + # indexServerBuild: + # runs-on: ubuntu-latest + # steps: + # - name: Check out registry support source code + # uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + # - name: Setup Go environment + # uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + # with: + # go-version: 1.19 + # - name: Login to Quay + # uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 + # with: + # registry: quay.io + # username: ${{ secrets.QUAY_USERNAME }} + # password: ${{ secrets.QUAY_PASSWORD }} + # - name: Build the index server base image + # run: | + # cd index/server + # export GOPATH=$(go env GOPATH) + # go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 + # bash ./build.sh + # - name: Push the index server base image + # run: cd index/server && bash ./push.sh quay.io/devfile/devfile-index-base:next - devfileRegistryIntegrationBuild: - runs-on: ubuntu-latest - steps: - - name: Check out registry support source code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - name: Login to Quay - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - - name: Build the index server base image - run: cd tests/integration && bash ./docker-build.sh - - name: Push the index server base image - run: cd tests/integration && bash ./docker-push.sh quay.io/devfile/devfile-registry-integration:next + # dispatch: + # needs: indexServerBuild + # strategy: + # matrix: + # repo: ['devfile/registry'] + # runs-on: ubuntu-latest + # steps: + # - name: Get the repository name and commit sha + # id: get_commit_info + # run: | + # # Check if repository name is not set in the client payload + # # If it's not set, the triggered commit came from this repo (registry-support) + # # If it is set, the triggered commit came from registry-viewer + # if [ -z ${{ github.event.client_payload.repo }} ]; + # then + # echo ::set-output name=repo::$(echo ${{ github.event.repository.name }}) + # else + # echo ::set-output name=repo::$(echo ${{ github.event.client_payload.repo }}) + # fi + + # # Check if commit sha is not set in the client payload + # # If it's not set, the triggered commit came from this repo (registry-support) + # # If it is set, the triggered commit came from registry-viewer + + # if [ -z ${{ github.event.client_payload.sha }} ]; + # then + # echo ::set-output name=sha::$(echo ${{ github.sha }}) + # else + # echo ::set-output name=sha::$(echo ${{ github.event.client_payload.sha }}) + # fi + # - name: Repository dispatch + # uses: peter-evans/repository-dispatch@v1 + # with: + # token: ${{ secrets.REPO_ACCESS_TOKEN }} + # repository: ${{ matrix.repo }} + # event-type: build + # client-payload: '{"repo": "${{ steps.get_commit_info.outputs.REPO }}", "sha": "${{ steps.get_commit_info.outputs.SHA }}"}' + + # ociRegistryBuild: + # runs-on: ubuntu-latest + # steps: + # - name: Check out registry support source code + # uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + # - name: Build and push oci-registry docker image + # uses: docker/build-push-action@v1.1.0 + # with: + # path: ./oci-registry + # username: ${{ secrets.QUAY_USERNAME }} + # password: ${{ secrets.QUAY_PASSWORD }} + # registry: quay.io + # repository: devfile/oci-registry + # dockerfile: ./oci-registry/Dockerfile + # tags: next + # tag_with_sha: true + + # devfileRegistryIntegrationBuild: + # runs-on: ubuntu-latest + # steps: + # - name: Check out registry support source code + # uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + # - name: Login to Quay + # uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 + # with: + # registry: quay.io + # username: ${{ secrets.QUAY_USERNAME }} + # password: ${{ secrets.QUAY_PASSWORD }} + # - name: Build the index server base image + # run: cd tests/integration && bash ./docker-build.sh + # - name: Push the index server base image + # run: cd tests/integration && bash ./docker-push.sh quay.io/devfile/devfile-registry-integration:next diff --git a/oci-registry/build-multi-arch.sh b/oci-registry/build-multi-arch.sh new file mode 100644 index 000000000..e0bf8f980 --- /dev/null +++ b/oci-registry/build-multi-arch.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +# +# Copyright Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Due to command differences between podman and docker we need to separate the process +# for creating and adding images to a multi-arch manifest +podman=${USE_PODMAN:-false} + +function build { + #IMAGE="quay.io/devfile/oci-registry:$2" + IMAGE="quay.io/rh-ee-jdubrick/oci-registry:$2" + + echo "Building: ${IMAGE}" + $1 build -t $IMAGE --platform "linux/$2" . + + echo "Pushing: ${IMAGE}" + $1 push $IMAGE + + +} + +function engine-handler { + for arch in amd64 arm64 ; do + build "$1" "$arch" + done +} + + +if [ ${podman} == true ]; then + echo "Executing with podman" + + # Build and push multi-arch images + engine-handler podman + # Create manifest and add images + + # Push and delete local manifest +else + echo "Executing with docker" + + engine-handler docker + # Build and push multi-arch images + + # Create manifest and add images + + # Push and delete local manifest +fi \ No newline at end of file