Skip to content

Commit b920cc1

Browse files
committed
Remove kubebuilder dependency
kubebuilder is not an actual dependency and is only installed in order to pull the binary assets required for the envtest package. This change pulls a controller-runtime script that helps with installing these assets, independently of kubebuilder. This means that we don't depend on the latter to release a new version which has pulled updates from upstream. This is apparently the recommended method (also how kubebuilder sets up new projects), see: - kubernetes-sigs/controller-runtime#1092 - https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3/Makefile#L17-L21 Signed-off-by: Dimitrios Karagiannis <[email protected]>
1 parent c7646b5 commit b920cc1

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Dockerfile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ FROM golang:1.15-alpine AS build
22

33
WORKDIR /src
44

5-
RUN apk --no-cache add git gcc musl-dev curl
5+
RUN apk --no-cache add git gcc musl-dev curl bash
66

77
ENV \
8-
KUBEBUILDER_VERSION=2.3.1 \
98
STRONGBOX_VERSION=0.2.0 \
109
KUBECTL_VERSION=v1.19.2 \
1110
KUSTOMIZE_VERSION=v3.8.5
@@ -17,15 +16,21 @@ RUN os=$(go env GOOS) && arch=$(go env GOARCH) &&\
1716
chmod +x /usr/local/bin/kustomize &&\
1817
curl -Ls -o /usr/local/bin/strongbox https://github.com/uw-labs/strongbox/releases/download/v${STRONGBOX_VERSION}/strongbox_${STRONGBOX_VERSION}_${os}_${arch} &&\
1918
chmod +x /usr/local/bin/strongbox &&\
20-
strongbox -git-config &&\
21-
curl -Ls https://go.kubebuilder.io/dl/${KUBEBUILDER_VERSION}/${os}/${arch} |\
22-
tar -xz -C /tmp/ &&\
23-
mv /tmp/kubebuilder_${KUBEBUILDER_VERSION}_${os}_${arch} /usr/local/kubebuilder
24-
ENV PATH=$PATH:/usr/local/kubebuilder/bin
19+
strongbox -git-config
2520

2621
COPY go.mod go.sum /src/
2722
RUN go mod download
2823

24+
ENV \
25+
ENVTEST_ASSETS_DIR=/usr/local/envtest \
26+
KUBEBUILDER_ASSETS=/usr/local/envtest/bin
27+
RUN /bin/bash -c '\
28+
mkdir -p ${ENVTEST_ASSETS_DIR} &&\
29+
controller_runtime_version=$(grep controller-runtime go.mod | cut -d" " -f2) &&\
30+
curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/${controller_runtime_version}/hack/setup-envtest.sh &&\
31+
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh &&\
32+
fetch_envtest_tools ${ENVTEST_ASSETS_DIR}'
33+
2934
COPY . /src
3035
RUN go get -t ./... &&\
3136
CGO_ENABLED=1 && go test -race -count=1 ./... &&\

0 commit comments

Comments
 (0)