Skip to content

Commit

Permalink
add Dockerfile for clusterctl (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
hchenxa authored and k8s-ci-robot committed Apr 20, 2019
1 parent af25ee9 commit 800c59e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand Down
32 changes: 32 additions & 0 deletions cmd/clusterctl/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 800c59e

Please sign in to comment.