Skip to content

Commit

Permalink
Move building image-detector to github workflow (#11996)
Browse files Browse the repository at this point in the history
* Move building image-detector to github workflow

* Cleanup go mod

* Add building the image
  • Loading branch information
KacperMalachowski authored Sep 27, 2024
1 parent cdf1657 commit 29c71d4
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pull-build-image-detector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: pull-build-image-detector
on:
pull_request_target:
types: [ opened, edited, synchronize, reopened, ready_for_review ]
paths:
- "cmd/image-detector/*.go"
- "cmd/image-detector/Dockerfile"
- "pkg/**"
- "go.mod"
- "go.sum"

jobs:
build-image:
uses: ./.github/workflows/image-builder.yml
with:
name: image-detector
dockerfile: cmd/image-detector/Dockerfile
context: .
print-image:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Print image
run: echo "Image built ${{ needs.build-image.outputs.images }}"
25 changes: 25 additions & 0 deletions .github/workflows/push-build-image-detector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: push-build-image-detector
on:
push:
branches:
- main
paths:
- "cmd/image-detector/*.go"
- "cmd/image-detector/Dockerfile"
- "pkg/**"
- "go.mod"
- "go.sum"

jobs:
build-image:
uses: ./.github/workflows/image-builder.yml
with:
name: image-detector
dockerfile: cmd/image-detector/Dockerfile
context: .
print-image:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Print image
run: echo "Image built ${{ needs.build-image.outputs.images }}"
1 change: 0 additions & 1 deletion .ko.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,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:
Expand Down
1 change: 0 additions & 1 deletion .koapps.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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
Expand Down
27 changes: 27 additions & 0 deletions cmd/image-detector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 . .

WORKDIR /app/cmd/image-detector

# 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-detector

# Copy the built Go app from the builder stage
COPY --from=builder /app/cmd/image-detector/main /image-detector

RUN apk add --no-cache ca-certificates git && \
chmod +x /image-detector
ENTRYPOINT ["/image-detector"]
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ require (
sigs.k8s.io/yaml v1.4.0
)

require github.com/rogpeppe/go-internal v1.11.0 // indirect

require (
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.9.5 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
Expand Down

0 comments on commit 29c71d4

Please sign in to comment.