diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index d365b8ff..6606e12d 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -61,10 +61,10 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v6 - timeout-minutes: 60 + timeout-minutes: 10 with: context: . platforms: ${{ env.platforms }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - push: true + push: ${{ github.event_name != 'pull_request' }} diff --git a/Dockerfile b/Dockerfile index f5be6230..37f7340e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.23 AS builder +FROM --platform=$BUILDPLATFORM golang:1.23.2 AS builder ARG TARGETOS ARG TARGETARCH @@ -23,7 +23,9 @@ COPY templates/ templates/ # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/go/pkg \ + CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/cmd/main.go b/cmd/main.go index f05d750d..90cefcf6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -23,6 +23,7 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + controllerconfig "sigs.k8s.io/controller-runtime/pkg/config" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" @@ -62,6 +63,7 @@ func main() { ctx := ctrl.LoggerInto(ctrl.SetupSignalHandler(), setupLog) defaultIpxeTemplateData := NewDefaultIPXETemplateData() defaultHttpUKIURL := NewDefaultHTTPBootData() + skipControllerNameValidation := true var metricsAddr string var enableLeaderElection bool @@ -155,7 +157,10 @@ func main() { SecureServing: secureMetrics, TLSOpts: tlsOpts, }, - WebhookServer: webhookServer, + WebhookServer: webhookServer, + Controller: controllerconfig.Controller{ + SkipNameValidation: &skipControllerNameValidation, + }, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "e9f0940b.ironcore.dev",