diff --git a/Makefile b/Makefile index 9bce4e6af4..4181546130 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"]