build: avoid docker export

docker export can result in changes to the image and is dependent on the docker daemon version. cache the tarball as a file instead.
This commit is contained in:
Bassam Tabbara committed 2017-06-20 20:57:46 -07:00
1 parent d52892bd12
commit 688ed6c0f2
2 files changed
+21 -5

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
# Copyright 2016 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 scratch
COPY ceph-install.tar /
+5 -5
View File
@@ -46,7 +46,6 @@ CEPH_IMAGE := $(BUILD_REGISTRY)/ceph-$(CEPH_CONFIG)-$$(docker images -q $(CEPH_B
IMAGES = $(CEPH_BUILDER_IMAGE) $(CEPH_IMAGE)
CACHE_IMAGES = $(IMAGES)
TEMP := $(shell mktemp -d)
# ====================================================================================
@@ -78,12 +77,13 @@ ceph:
$(CEPH_BUILDER_IMAGE)
@docker cp `cat $(TEMP)/cid`:/build/$(CEPH_TARBALL) $(TEMP)/$(CEPH_TARBALL)
@docker rm -f `cat $(TEMP)/cid`
@docker import $(TEMP)/$(CEPH_TARBALL) $(CEPH_IMAGE)
@rm -fr $(TEMP)/cid
# now cache the ceph tarball in a docker image
@cp Dockerfile.ceph $(TEMP)/Dockerfile
@docker build $(BUILD_ARGS) -t $(CEPH_IMAGE) $(TEMP)
@rm -fr $(TEMP)
# export the ceph tarball removing any files added by ceph that could make it
# different and result in dependent images being rebuilt
%/$(CEPH_TARBALL): build
@CID=`docker create $(CEPH_IMAGE) /dev/null` &&\
docker export $$CID | tar --delete -f - .dockerenv etc dev proc sys > $@ &&\
docker cp $$CID:$(CEPH_TARBALL) $@ &&\
docker rm -f $$CID