Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile update to use Go as builder #12006

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull-build-image-autobumper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/push-build-image-autobumper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand All @@ -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:
Expand Down
20 changes: 17 additions & 3 deletions cmd/image-autobumper/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Loading