diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b268db94..20eb8522 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,7 +1,7 @@ name: Pull Request on: - pull_request_target: + pull_request: branches: - 'master' paths-ignore: @@ -32,23 +32,12 @@ jobs: with: go-version: ${{ env.GOLANG_VERSION }} - - name: Lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.50.1 - only-new-issues: false - args: --timeout 10m - # Set up helm binary - name: Set up Helm uses: azure/setup-helm@v3 with: version: ${{ env.HELM_VERSION }} - - name: Helm Lint - run: | - helm lint charts/ingressmonitorcontroller - - name: Install kind uses: engineerd/setup-kind@v0.5.0 with: @@ -67,9 +56,6 @@ jobs: mkdir -p .local echo "${{ secrets.SECRET_KUBERNETES_RESOURCES }}" | base64 --decode > .local/test-config.yaml - - name: Test - run: make test - - name: Generate Tag id: generate_tag run: | @@ -82,10 +68,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - with: - driver-opts: | - image=moby/buildkit:v0.9.3 - buildkitd-flags: --debug - name: Login to Registry uses: docker/login-action@v2 @@ -104,7 +86,9 @@ jobs: file: ${{ env.DOCKER_FILE_PATH }} pull: true push: true + build-args: BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }} cache-to: type=inline + platforms: linux/amd64,linux/arm,linux/arm64 tags: | ${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }} labels: | diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e624f4f8..3e6f9de2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -115,6 +115,7 @@ jobs: pull: true push: true cache-to: type=inline + platforms: linux/amd64,linux/arm,linux/arm64 tags: | ${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.new_tag }} labels: | diff --git a/Dockerfile b/Dockerfile index 647cfba6..b153f47f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # Build the manager binary -FROM golang:1.18 as builder +ARG BUILDER_IMAGE +ARG BASE_IMAGE +FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE:-golang:1.18} as builder WORKDIR /workspace # Copy the Go Modules manifests @@ -15,11 +17,13 @@ COPY api/ api/ COPY pkg/ pkg/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -mod=mod -a -o manager main.go +ARG TARGETARCH +ARG TARGETOS +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -mod=mod -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 -FROM gcr.io/distroless/static:nonroot +FROM ${BASE_IMAGE:-gcr.io/distroless/static:nonroot} WORKDIR / COPY --from=builder /workspace/manager . USER 65532:65532