From 7c82304b7f9d5dbe9c6bdb4f09742481dddd6881 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 4 Mar 2016 18:31:58 -0700 Subject: [PATCH] fix(*): allow local docker registry This fix supersedes #323. It applies basically the same fixes: - local docker registries are now supported - kubectl is not downloaded on every build Also, added a fix for the case where `docker version` failed because the Docker daemon crashed, and consequently spuriously propmted the user to re-install docker. I added support for $DOCKER_PROJECT instead of just $PROJECT because the later is a little too generic for a shell env var. We can deprecate $PROJECT later. I did not add back in the better tool checks in bootstrap because CircleCI doesn't have the `command` command. --- .gitignore | 2 ++ rootfs/include.mk | 27 ++++++++++++++++++++++++--- rootfs/manager/Makefile | 5 ----- rootfs/resourcifier/Makefile | 5 ----- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 875c22e57..a87d17f5e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,9 @@ /vendor/* /rootfs/manager/bin/manager /rootfs/manager/bin/kubectl +/rootfs/manager/bin/v1.* /rootfs/resourcifier/bin/resourcifier /rootfs/resourcifier/bin/kubectl +/rootfs/resourcifier/bin/v1.* /rootfs/expandybird/bin/expandybird /rootfs/expandybird/opt/expansion diff --git a/rootfs/include.mk b/rootfs/include.mk index 43d779adb..a7e3948d2 100644 --- a/rootfs/include.mk +++ b/rootfs/include.mk @@ -15,7 +15,17 @@ # If you update this image please check the tag value before pushing. DOCKER_REGISTRY ?= gcr.io -PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) + +# Legacy support for $PROJECT +DOCKER_PROJECT ?= $(PROJECT) + +# Support both local and remote repos, and support no project. +ifdef $(DOCKER_PROJECT) +PREFIX := $(DOCKER_REGISTRY)/$(DOCKER_PROJECT) +else +PREFIX := $(DOCKER_REGISTRY) +endif + FULL_IMAGE := $(PREFIX)/$(IMAGE) TAG ?= git-$(shell git rev-parse --short HEAD) @@ -26,6 +36,7 @@ PLATFORM ?= $(DEFAULT_PLATFORM) DEFAULT_ARCH := $(shell uname -m) ARCH ?= $(DEFAULT_ARCH) + .PHONY: info info: @echo "Build tag: ${TAG}" @@ -51,10 +62,12 @@ container: .project .docker binary extras docker tag -f $(FULL_IMAGE):latest $(FULL_IMAGE):$(TAG) .project: - @if [[ -z "${PROJECT}" ]]; then echo "PROJECT variable must be set"; exit 1; fi +ifeq ($(DOCKER_REGISTRY), gcr.io) + $(error "One or both of DOCKER_REGISTRY and DOCKER_PROJECT must be set.") +endif .docker: - @if [[ -z `which docker` ]] || ! docker version &> /dev/null; then echo "docker is not installed correctly"; exit 1; fi + @if [[ -z `which docker` ]] || ! docker --version &> /dev/null; then echo "docker is not installed correctly"; exit 1; fi CROSS_IMAGE := $(PLATFORM)-$(ARCH)/$(IMAGE)/$(IMAGE) @@ -67,3 +80,11 @@ binary: echo cp ../../bin/$(IMAGE) ./bin ; \ cp ../../bin/$(IMAGE) ./bin ; \ fi + +.PHONY: kubectl +kubectl: +ifeq ("$(wildcard bin/$(KUBE_VERSION))", "") + touch bin/$(KUBE_VERSION) + curl -fsSL -o bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl + chmod +x bin/kubectl +endif diff --git a/rootfs/manager/Makefile b/rootfs/manager/Makefile index 4c38b8e40..0b1f4c681 100644 --- a/rootfs/manager/Makefile +++ b/rootfs/manager/Makefile @@ -19,8 +19,3 @@ include ../include.mk .PHONY: extras extras: kubectl - -.PHONY: kubectl -kubectl: - curl -fsSL -o bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl - chmod +x bin/kubectl diff --git a/rootfs/resourcifier/Makefile b/rootfs/resourcifier/Makefile index d1a62ebca..bbf66ee66 100644 --- a/rootfs/resourcifier/Makefile +++ b/rootfs/resourcifier/Makefile @@ -19,8 +19,3 @@ include ../include.mk .PHONY: extras extras: kubectl - -.PHONY: kubectl -kubectl: - curl -fsSL -o bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl - chmod +x bin/kubectl