From 3109408bd0b7101184df6f6cd0266ddd283d222e Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Sat, 20 Apr 2019 10:37:41 +0800 Subject: [PATCH] add Dockerfile for clusterctl (#305) --- Makefile | 6 +++++- cmd/clusterctl/Dockerfile | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cmd/clusterctl/Dockerfile diff --git a/Makefile b/Makefile index 8cce96bae6..805918d06c 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,7 @@ generate: manifests manifests: go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd -images: openstack-cluster-api-controller manifests +images: openstack-cluster-api-controller clusterctl-image manifests openstack-cluster-api-controller: depend manager manifests ifeq ($(GOOS),linux) @@ -145,10 +145,14 @@ else $(error Please set GOOS=linux for building the image) endif +clusterctl-image: generate fmt vet manifests + docker build . -f cmd/clusterctl/Dockerfile -t "$(REGISTRY)/openstack-cluster-api-clusterctl:$(VERSION)" + upload-images: images @echo "push images to $(REGISTRY)" docker login -u="$(DOCKER_USERNAME)" -p="$(DOCKER_PASSWORD)"; docker push $(REGISTRY)/openstack-cluster-api-controller:$(VERSION) + docker push $(REGISTRY)/openstack-cluster-api-clusterctl:$(VERSION) version: @echo ${VERSION} diff --git a/cmd/clusterctl/Dockerfile b/cmd/clusterctl/Dockerfile new file mode 100644 index 0000000000..02d2c0fb16 --- /dev/null +++ b/cmd/clusterctl/Dockerfile @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Build the cluster binary +FROM golang:1.10.3 as builder + +# Copy in the go src +WORKDIR /go/src/sigs.k8s.io/cluster-api-provider-openstack +COPY pkg/ pkg/ +COPY cmd/ cmd/ +COPY vendor/ vendor/ + +# Build +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o clusterctl sigs.k8s.io/cluster-api-provider-openstack/cmd/clusterctl + +# Copy clusterctl into a thin image +FROM debian:stretch-slim +WORKDIR /root/ + +RUN apt-get update && apt-get install -y ca-certificates openssh-client + +COPY --from=builder /go/src/sigs.k8s.io/cluster-api-provider-openstack/clusterctl . +ENTRYPOINT ["./clusterctl"]