From a80f05cf519bef1a5ebb3c4bf317ebf94270b39b Mon Sep 17 00:00:00 2001 From: Jared Watts Date: Mon, 18 Jun 2018 17:09:45 -0700 Subject: [PATCH] cockroachdb: rook/cockroachdb image build Signed-off-by: Jared Watts --- build/codegen/codegen.sh | 2 +- build/release/Makefile | 2 +- build/release/README.md | 1 + images/Makefile | 5 +++- images/cockroachdb/Dockerfile | 20 +++++++++++++++ images/cockroachdb/Makefile | 47 +++++++++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 images/cockroachdb/Dockerfile create mode 100755 images/cockroachdb/Makefile diff --git a/build/codegen/codegen.sh b/build/codegen/codegen.sh index 6169d9ea4..9ec3880d5 100755 --- a/build/codegen/codegen.sh +++ b/build/codegen/codegen.sh @@ -23,7 +23,7 @@ cd "${scriptdir}/../../vendor/k8s.io/code-generator" && ./generate-groups.sh \ all \ github.com/rook/rook/pkg/client \ github.com/rook/rook/pkg/apis \ - "rook.io:v1alpha1,v1alpha2 ceph.rook.io:v1alpha1" + "rook.io:v1alpha1,v1alpha2 ceph.rook.io:v1alpha1 cockroachdb.rook.io:v1alpha1" # this seems busted in the release-1.8 branch # --go-header-file ${SCRIPT_ROOT}/build/codegen/header.txt diff --git a/build/release/Makefile b/build/release/Makefile index 7de7eba61..1a304f05c 100644 --- a/build/release/Makefile +++ b/build/release/Makefile @@ -58,7 +58,7 @@ endif DOCKER_REGISTRY ?= rook QUAY_REGISTRY ?= quay.io/rook REGISTRIES ?= $(DOCKER_REGISTRY) $(QUAY_REGISTRY) -IMAGES ?= ceph ceph-toolbox +IMAGES ?= ceph ceph-toolbox cockroachdb IMAGE_ARCHS := $(subst linux_,,$(filter linux_%,$(PLATFORMS))) IMAGE_PLATFORMS := $(subst _,/,$(subst $(SPACE),$(COMMA),$(filter linux_%,$(PLATFORMS)))) diff --git a/build/release/README.md b/build/release/README.md index 4e565ede7..5cf12fa08 100644 --- a/build/release/README.md +++ b/build/release/README.md @@ -66,4 +66,5 @@ Containers go to docker hub and quay.io where we have the following repos: ``` rook/ceph rook/ceph-toolbox +rook/cockroachdb ``` diff --git a/images/Makefile b/images/Makefile index f2c972100..914dfffd0 100644 --- a/images/Makefile +++ b/images/Makefile @@ -35,7 +35,10 @@ ceph.%: ceph-toolbox.%: ceph.% @$(MAKE) -C ceph-toolbox PLATFORM=$* -do.build.images.%: ceph.% ceph-toolbox.% ; +cockroachdb.%: + @$(MAKE) -C cockroachdb PLATFORM=$* + +do.build.images.%: ceph.% ceph-toolbox.% cockroachdb.% ; do.build: do.build.images.$(PLATFORM) ; build.all: $(foreach p,$(PLATFORMS), do.build.images.$(p)) ; diff --git a/images/cockroachdb/Dockerfile b/images/cockroachdb/Dockerfile new file mode 100644 index 000000000..bd99b08ad --- /dev/null +++ b/images/cockroachdb/Dockerfile @@ -0,0 +1,20 @@ +# Copyright 2018 The Rook Authors. All rights reserved. +# +# 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. + +FROM cockroachdb/cockroach:v2.0.2 + +ADD rook /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/rook"] +CMD [""] diff --git a/images/cockroachdb/Makefile b/images/cockroachdb/Makefile new file mode 100755 index 000000000..77e814504 --- /dev/null +++ b/images/cockroachdb/Makefile @@ -0,0 +1,47 @@ +# Copyright 2018 The Rook Authors. All rights reserved. +# +# 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. + +include ../image.mk + +# ==================================================================================== +# Image Build Options + +COCKROACHDB_IMAGE = $(BUILD_REGISTRY)/cockroachdb-$(GOARCH) +IMAGES = $(COCKROACHDB_IMAGE) + +TEMP := $(shell mktemp -d) + +# ==================================================================================== +# Build Rook CockroachDB + +# since this is a leaf image we avoid leaving around a lot of dangling images +# by removing the last build of the final cockroachdb image +OLD_IMAGE_ID := $(shell docker images -q $(COCKROACHDB_IMAGE)) +CURRENT_IMAGE_ID := $$(docker images -q $(COCKROACHDB_IMAGE)) +IMAGE_FILENAME := $(IMAGE_OUTPUT_DIR)/cockroachdb.tar.gz + +do.build: + @echo === docker build $(COCKROACHDB_IMAGE) + @cp Dockerfile $(TEMP) + @cp $(OUTPUT_DIR)/bin/linux_$(GOARCH)/rook $(TEMP) + @docker build $(BUILD_ARGS) \ + -t $(COCKROACHDB_IMAGE) \ + $(TEMP) + @[ "$(OLD_IMAGE_ID)" != "$(CURRENT_IMAGE_ID)" ] && [ -n "$(OLD_IMAGE_ID)" ] && docker rmi $(OLD_IMAGE_ID) || true + @if [ ! -e "$(IMAGE_FILENAME)" ] || [ "$(OLD_IMAGE_ID)" != "$(CURRENT_IMAGE_ID)" ] || [ -n "$(OLD_IMAGE_ID)" ]; then \ + echo === saving image $(COCKROACHDB_IMAGE); \ + mkdir -p $(IMAGE_OUTPUT_DIR); \ + docker save $(COCKROACHDB_IMAGE) | gzip -c > $(IMAGE_FILENAME); \ + fi + @rm -fr $(TEMP)