diff --git a/hack/build-image/Dockerfile b/hack/build-image/Dockerfile index e63a1c911..4e0d4f8f2 100644 --- a/hack/build-image/Dockerfile +++ b/hack/build-image/Dockerfile @@ -12,40 +12,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.12 +FROM golang:1.13 +# Use a proxy for go modules to reduce the likelihood of various hosts being down and breaking the build +ENV GOPROXY=https://proxy.golang.org + +# get code-generation tools (for now keep in GOPATH since they're not fully modules-compatible yet) RUN mkdir -p /go/src/k8s.io WORKDIR /go/src/k8s.io RUN git config --global advice.detachedHead false RUN git clone -b kubernetes-1.17.0 https://github.com/kubernetes/code-generator -RUN git clone -b kubernetes-1.17.0 https://github.com/kubernetes/apimachinery -# Use a proxy for go modules to reduce the likelihood of various hosts being down and breaking the build -ENV GOPROXY=https://proxy.golang.org # vendor code-generator go modules to be compatible with pre-1.15 -WORKDIR /go/src/k8s.io/code-generator +WORKDIR /go/src/k8s.io/code-generator # Don't use ENV here because we don't want to disable modules for subsequent commands RUN GO111MODULE=on go mod vendor -RUN mkdir -p /go/src/sigs.k8s.io -WORKDIR /go/src/sigs.k8s.io -RUN git clone -b v0.2.4 https://github.com/kubernetes-sigs/controller-tools -WORKDIR /go/src/sigs.k8s.io/controller-tools -RUN GO111MODULE=on go mod vendor -RUN go get golang.org/x/tools/cmd/goimports -WORKDIR /go/src/golang.org/x/tools -RUN git checkout 40a48ad93fbe707101afb2099b738471f70594ec -RUN go install ./cmd/goimports -RUN echo chmod -R a+w /go + +# get controller-tools +RUN GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.4 + +# get goimports (the revision is pinned so we don't indiscriminately update, but the particular commit +# is not important) +RUN GO111MODULE=on go get golang.org/x/tools/cmd/goimports@11e9d9cc0042e6bd10337d4d2c3e5d9295508e7d + +# get protoc compiler and golang plugin WORKDIR /root RUN apt-get update && apt-get install -y unzip RUN wget --quiet https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip && \ unzip protoc-3.9.1-linux-x86_64.zip && \ mv bin/protoc /usr/bin/protoc && \ chmod +x /usr/bin/protoc -RUN mkdir -p /go/src/github.com/golang -WORKDIR /go/src/github.com/golang -RUN git clone -b v1.0.0 https://github.com/golang/protobuf -WORKDIR /go/src/github.com/golang/protobuf -RUN go install ./protoc-gen-go +RUN GO111MODULE=on go get github.com/golang/protobuf/protoc-gen-go@v1.0.0 + +# get goreleaser RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v0.120.8/goreleaser_Linux_x86_64.tar.gz && \ tar xvf goreleaser_Linux_x86_64.tar.gz && \ mv goreleaser /usr/bin/goreleaser && \ diff --git a/hack/update-generated-crd-code.sh b/hack/update-generated-crd-code.sh index 3dabff609..34bcd1d65 100755 --- a/hack/update-generated-crd-code.sh +++ b/hack/update-generated-crd-code.sh @@ -28,8 +28,8 @@ if [[ ! -d "${GOPATH}/src/k8s.io/code-generator" ]]; then exit 1 fi -if [[ ! -d "${GOPATH}/src/sigs.k8s.io/controller-tools" ]]; then - echo "sigs.k8s.io/controller-tools missing from GOPATH" +if ! command -v controller-gen > /dev/null; then + echo "controller-gen is missing" exit 1 fi @@ -41,7 +41,7 @@ ${GOPATH}/src/k8s.io/code-generator/generate-groups.sh \ --go-header-file ${GOPATH}/src/github.com/vmware-tanzu/velero/hack/boilerplate.go.txt \ $@ -go run ${GOPATH}/src/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \ +controller-gen \ crd:crdVersions=v1beta1,preserveUnknownFields=false \ output:dir=pkg/generated/crds/manifests \ paths=./pkg/apis/velero/v1/...