diff --git a/.github/workflows/build-images-base.yaml b/.github/workflows/build-images-base.yaml index 3489ff324..92357a25e 100644 --- a/.github/workflows/build-images-base.yaml +++ b/.github/workflows/build-images-base.yaml @@ -85,48 +85,38 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3 - - name: Install qemu dependency - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - name: Build Image - id: build-image - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.OPERATOR_NAME }} - tags: ${{ env.IMG_TAGS }} - platforms: linux/amd64,linux/arm64 - dockerfiles: | - ./Dockerfile - - name: Push Image - if: ${{ !env.ACT }} - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to container registry + uses: docker/login-action@v2 with: - image: ${{ steps.build-image.outputs.image }} - tags: ${{ steps.build-image.outputs.tags }} - registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} username: ${{ secrets.IMG_REGISTRY_USERNAME }} password: ${{ secrets.IMG_REGISTRY_TOKEN }} + registry: ${{ env.IMG_REGISTRY_HOST }} + - name: Build and Push Image + id: build-image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}:${{ env.IMG_TAGS }} - name: Print Image URL - run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + run: echo "Image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}:${{ env.IMG_TAGS }}" build-bundle: needs: build name: Build Bundle runs-on: ubuntu-latest steps: + - name: Check out code + uses: actions/checkout@v3 - name: Set up Go 1.21.x uses: actions/setup-go@v4 with: go-version: 1.21.x - id: go - - name: Check out code - uses: actions/checkout@v3 - - name: Install qemu dependency - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - name: Run make bundle id: make-bundle run: | @@ -138,40 +128,38 @@ jobs: WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }} \ REPLACES_VERSION=${{ inputs.replacesVersion }} \ CHANNELS=${{ inputs.channels }} - - name: Build Image - id: build-image - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.OPERATOR_NAME }}-bundle - tags: ${{ env.IMG_TAGS }} - platforms: linux/amd64,linux/arm64 - dockerfiles: | - ./bundle.Dockerfile - - name: Push Image - if: ${{ !env.ACT }} - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to container registry + uses: docker/login-action@v2 with: - image: ${{ steps.build-image.outputs.image }} - tags: ${{ steps.build-image.outputs.tags }} - registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} username: ${{ secrets.IMG_REGISTRY_USERNAME }} password: ${{ secrets.IMG_REGISTRY_TOKEN }} - - name: Print Image URL - run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + registry: ${{ env.IMG_REGISTRY_HOST }} + - name: Build and Push Bundle Image + id: build-bundle-image + uses: docker/build-push-action@v5 + with: + context: . + file: ./bundle.Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-bundle:${{ env.IMG_TAGS }} + - name: Print Bundle Image URL + run: echo "Bundle image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-bundle:${{ env.IMG_TAGS }}" build-catalog: name: Build Catalog needs: [build, build-bundle] runs-on: ubuntu-latest steps: + - name: Check out code + uses: actions/checkout@v3 - name: Set up Go 1.21.x uses: actions/setup-go@v4 with: go-version: 1.21.x - id: go - - name: Check out code - uses: actions/checkout@v3 - name: Generate Catalog Content run: | make catalog REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ @@ -182,29 +170,23 @@ jobs: WASM_SHIM_VERSION=${{ inputs.wasmShimVersion }} \ REPLACES_VERSION=${{ inputs.replacesVersion }} \ CHANNELS=${{ inputs.channels }} - - name: Install qemu dependency - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - name: Build Image - id: build-image - uses: redhat-actions/buildah-build@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to container registry + uses: docker/login-action@v2 with: - image: ${{ env.OPERATOR_NAME }}-catalog - tags: ${{ env.IMG_TAGS }} - platforms: linux/amd64,linux/arm64 - context: ./catalog - dockerfiles: | - ./catalog/kuadrant-operator-catalog.Dockerfile - - name: Push Image - if: ${{ !env.ACT }} - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build-image.outputs.image }} - tags: ${{ steps.build-image.outputs.tags }} - registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} username: ${{ secrets.IMG_REGISTRY_USERNAME }} password: ${{ secrets.IMG_REGISTRY_TOKEN }} - - name: Print Image URL - run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" \ No newline at end of file + registry: ${{ env.IMG_REGISTRY_HOST }} + - name: Build and Push Catalog Image + id: build-catalog-image + uses: docker/build-push-action@v5 + with: + context: ./catalog + file: ./catalog/kuadrant-operator-catalog.Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-catalog:${{ env.IMG_TAGS }} + - name: Print Catalog Image URL + run: echo "Catalog image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-catalog:${{ env.IMG_TAGS }}" \ No newline at end of file diff --git a/.github/workflows/build-images-pr.yaml b/.github/workflows/build-images-pr.yaml deleted file mode 100644 index 13afac648..000000000 --- a/.github/workflows/build-images-pr.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: PR Conditional Build and Push Image to Quay.io Repo - -on: - pull_request_target: - types: [labeled, opened, synchronize, reopened] - -jobs: - workflow-build: - if: contains(github.event.pull_request.labels.*.name, 'forked_image_approved') - name: Calls build-images-base - uses: ./.github/workflows/build-images-base.yaml - secrets: inherit - with: - kuadrantOperatorVersion: ${{ github.event.pull_request.user.login }}-${{ github.event.pull_request.number }} - kuadrantOperatorTag: ${{ github.event.pull_request.user.login }}-${{ github.event.pull_request.number }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 52d1aed47..02e21f035 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,11 +16,11 @@ COPY controllers/ controllers/ COPY pkg/ pkg/ # Set environment variables for cross-compilation -ARG TARGETPLATFORM +#ARG TARGETPLATFORM ARG TARGETARCH # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o manager main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details