From a53af30d2361416f906c2e30a54aefcb1deebb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Mon, 8 Jul 2024 11:57:56 +0200 Subject: [PATCH] chore(dev): speed up image build with ko Ko builds the binary locally and utilizes the local go build cache. This makes the deployment with skaffold faster locally and in our e2e tests. This makes the dev setup more different than the production setup (still using Dockerfile). But they were already a bit different anyway. In the mid-term I want to use `ko` for the production images too. --- dev/Dockerfile | 23 ----------------------- skaffold.yaml | 5 +---- 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 dev/Dockerfile diff --git a/dev/Dockerfile b/dev/Dockerfile deleted file mode 100644 index 18616db35..000000000 --- a/dev/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM golang:1.22 as builder - -WORKDIR /build - -ADD go.mod go.sum /build/ -RUN go mod download - -ADD . /build/ -RUN ls -al - -ARG CGO_ENABLED=0 -# `skaffold debug` sets SKAFFOLD_GO_GCFLAGS to disable compiler optimizations -ARG SKAFFOLD_GO_GCFLAGS -RUN go build -gcflags="$SKAFFOLD_GO_GCFLAGS" -o hcloud-cloud-controller-manager.bin github.com/hetznercloud/hcloud-cloud-controller-manager - -FROM alpine:3.20 - -RUN apk add --no-cache \ - bash \ - ca-certificates - -COPY --from=builder /build/hcloud-cloud-controller-manager.bin /bin/hcloud-cloud-controller-manager -ENTRYPOINT ["/bin/hcloud-cloud-controller-manager"] diff --git a/skaffold.yaml b/skaffold.yaml index 3852a620e..e4150c7b2 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -5,10 +5,7 @@ metadata: build: artifacts: - image: docker.io/hetznercloud/hcloud-cloud-controller-manager - docker: - dockerfile: dev/Dockerfile - local: - useBuildkit: true + ko: {} insecureRegistries: - localhost:30666