FROM golang:1.21-alpine AS builder WORKDIR /app # Install git for cloning repositories RUN apk add --no-cache git # Copy go mod files COPY go.mod go.sum ./ RUN go mod download # Copy source code COPY . . # Build the application RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o manager ./cmd/manager # Final stage FROM alpine:latest # Install git and docker client RUN apk add --no-cache git docker-cli WORKDIR /root/ # Copy the binary from builder stage COPY --from=builder /app/manager . # Copy manifests COPY --from=builder /app/manifests ./manifests # Expose port EXPOSE 8080 # Run the application CMD ["./manager"]