From e50014920759a3ad2ee4c86348435aec76c7137c Mon Sep 17 00:00:00 2001 From: Patryk Dobrowolski Date: Fri, 27 Sep 2024 12:09:11 +0200 Subject: [PATCH 1/5] Removal of ko, image-autobumper --- .../push-build-image-autobumper.yaml | 25 +++++++++++++++++++ .ko.yaml | 1 - .koapps.yaml | 1 - cmd/image-autobumper/Dockerfile | 13 ++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push-build-image-autobumper.yaml create mode 100644 cmd/image-autobumper/Dockerfile diff --git a/.github/workflows/push-build-image-autobumper.yaml b/.github/workflows/push-build-image-autobumper.yaml new file mode 100644 index 000000000000..4771e114fb24 --- /dev/null +++ b/.github/workflows/push-build-image-autobumper.yaml @@ -0,0 +1,25 @@ +name: push-build-image-autobumper +on: + push: + branches: + - main + paths: + - 'cmd/image-detector/Dockerfile' + - 'cmd/image-detector/**' + - 'go.mod' + - 'go.sum' + workflow_dispatch: {} + +jobs: + build-image: + uses: ./.github/workflows/image-builder.yml + with: + name: image-detector + dockerfile: cmd/image-autobumper/Dockerfile + context: . + print-image: + runs-on: ubuntu-latest + needs: build-image + steps: + - name: Print image + run: echo "Image built ${{ needs.build-image.outputs.images }}" diff --git a/.ko.yaml b/.ko.yaml index f609a3aa252c..d93e39fffb35 100644 --- a/.ko.yaml +++ b/.ko.yaml @@ -2,7 +2,6 @@ baseImageOverrides: github.com/kyma-project/test-infra/cmd/tools/pjtester: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 github.com/kyma-project/test-infra/cmd/markdown-index: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 github.com/kyma-project/test-infra/cmd/image-detector: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 - github.com/kyma-project/test-infra/cmd/image-autobumper: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 github.com/kyma-project/test-infra/cmd/external-plugins/automated-approver: europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 defaultPlatforms: - linux/arm64 diff --git a/.koapps.yaml b/.koapps.yaml index d0da7f93c375..a9c2bd3a42b2 100644 --- a/.koapps.yaml +++ b/.koapps.yaml @@ -1,7 +1,6 @@ apps: - ko://github.com/kyma-project/test-infra/cmd/tools/pjtester - ko://github.com/kyma-project/test-infra/cmd/image-detector - - ko://github.com/kyma-project/test-infra/cmd/image-autobumper - ko://github.com/kyma-project/test-infra/cmd/image-url-helper - ko://github.com/kyma-project/test-infra/cmd/markdown-index - ko://github.com/kyma-project/test-infra/cmd/tools/usersmapchecker diff --git a/cmd/image-autobumper/Dockerfile b/cmd/image-autobumper/Dockerfile new file mode 100644 index 000000000000..7739566bc9bb --- /dev/null +++ b/cmd/image-autobumper/Dockerfile @@ -0,0 +1,13 @@ +FROM europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o image-autobumper ./cmd/image-autobumper + +ENTRYPOINT ["./image-autobumper"] From 4bf98891b787064a024d4e12d8980764d1c069ae Mon Sep 17 00:00:00 2001 From: Patryk Dobrowolski Date: Fri, 27 Sep 2024 12:21:29 +0200 Subject: [PATCH 2/5] Pull build action --- .../pull-build-image-autobumper.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pull-build-image-autobumper.yaml diff --git a/.github/workflows/pull-build-image-autobumper.yaml b/.github/workflows/pull-build-image-autobumper.yaml new file mode 100644 index 000000000000..6aec246e026a --- /dev/null +++ b/.github/workflows/pull-build-image-autobumper.yaml @@ -0,0 +1,23 @@ +name: pull-build-image-autobumper +on: + pull_request_target: + types: [ opened, edited, synchronize, reopened, ready_for_review ] + paths: + - "cmd/image-syncer/*.go" + - "cmd/image-syncer/Dockerfile" + - "go.mod" + - "go.sum" + +jobs: + build-image: + uses: ./.github/workflows/image-builder.yml + with: + name: image-autobumper + dockerfile: cmd/image-autobumper/Dockerfile + context: . + print-image: + runs-on: ubuntu-latest + needs: build-image + steps: + - name: Print image + run: echo "Image built ${{ needs.build-image.outputs.images }}" \ No newline at end of file From bf84f9e616362f9d00415d78d32c933204db26e0 Mon Sep 17 00:00:00 2001 From: Patryk Dobrowolski Date: Fri, 27 Sep 2024 12:41:34 +0200 Subject: [PATCH 3/5] fix typo --- .github/workflows/push-build-image-autobumper.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-build-image-autobumper.yaml b/.github/workflows/push-build-image-autobumper.yaml index 4771e114fb24..549363d568ba 100644 --- a/.github/workflows/push-build-image-autobumper.yaml +++ b/.github/workflows/push-build-image-autobumper.yaml @@ -14,7 +14,7 @@ jobs: build-image: uses: ./.github/workflows/image-builder.yml with: - name: image-detector + name: image-autobumper dockerfile: cmd/image-autobumper/Dockerfile context: . print-image: From d771d2347d6e6af9ac6eba37ed51758000320b13 Mon Sep 17 00:00:00 2001 From: Patryk Dobrowolski Date: Fri, 27 Sep 2024 12:46:43 +0200 Subject: [PATCH 4/5] more typos --- .github/workflows/pull-build-image-autobumper.yaml | 4 ++-- .github/workflows/push-build-image-autobumper.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-build-image-autobumper.yaml b/.github/workflows/pull-build-image-autobumper.yaml index 6aec246e026a..7457be849462 100644 --- a/.github/workflows/pull-build-image-autobumper.yaml +++ b/.github/workflows/pull-build-image-autobumper.yaml @@ -3,8 +3,8 @@ on: pull_request_target: types: [ opened, edited, synchronize, reopened, ready_for_review ] paths: - - "cmd/image-syncer/*.go" - - "cmd/image-syncer/Dockerfile" + - 'cmd/image-autobumper/Dockerfile' + - 'cmd/image-autobumper/**' - "go.mod" - "go.sum" diff --git a/.github/workflows/push-build-image-autobumper.yaml b/.github/workflows/push-build-image-autobumper.yaml index 549363d568ba..95053c60bf00 100644 --- a/.github/workflows/push-build-image-autobumper.yaml +++ b/.github/workflows/push-build-image-autobumper.yaml @@ -4,8 +4,8 @@ on: branches: - main paths: - - 'cmd/image-detector/Dockerfile' - - 'cmd/image-detector/**' + - 'cmd/image-autobumper/Dockerfile' + - 'cmd/image-autobumper/**' - 'go.mod' - 'go.sum' workflow_dispatch: {} From f634f9c47f8736b600b21fe0bf052e768065184e Mon Sep 17 00:00:00 2001 From: Patryk Dobrowolski Date: Fri, 27 Sep 2024 12:59:45 +0200 Subject: [PATCH 5/5] test of dockerfile on PR --- cmd/image-autobumper/Dockerfile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/image-autobumper/Dockerfile b/cmd/image-autobumper/Dockerfile index 7739566bc9bb..6b58658b1a97 100644 --- a/cmd/image-autobumper/Dockerfile +++ b/cmd/image-autobumper/Dockerfile @@ -1,13 +1,27 @@ -FROM europe-docker.pkg.dev/kyma-project/prod/testimages/alpine-git:v20240924-6fb36f45 +FROM golang:1.23-alpine as builder WORKDIR /app COPY go.mod go.sum ./ +# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed RUN go mod download +# Copy the source to the Working Directory inside the container COPY . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o image-autobumper ./cmd/image-autobumper +WORKDIR /app/cmd/image-autobumper -ENTRYPOINT ["./image-autobumper"] +# Build the Go app with static linking +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . + +FROM alpine:3.20.3 + +LABEL io.kyma-project.source=github.com/kyma-project/test-infra/cmd/image-autobumper + +# Copy the built Go app from the builder stage +COPY --from=builder /app/cmd/image-autobumper/main /image-autobumper + +RUN apk add --no-cache ca-certificates git && \ + chmod +x /image-autobumper +ENTRYPOINT ["/image-autobumper"] \ No newline at end of file