From 2902908497ef03a65419e7bc22f2f90cab844ff1 Mon Sep 17 00:00:00 2001 From: Brett Logan Date: Sun, 15 Dec 2019 23:12:35 -0500 Subject: [PATCH] [FAB-17272] Fix Docker Build Context This change explicitly excludes unneeded directories by extending .dockerignore and introduces a BUILD_CONTEXT variable in the Makefile to limit the scope of the build context for ccenv and baseos which do not require the fabric source code in its context. Signed-off-by: Brett Logan --- .dockerignore | 17 +++++++++++++++-- Makefile | 6 ++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index e04d6853be4..a40625b1346 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,5 +3,18 @@ # # SPDX-License-Identifier: Apache-2.0 # -.build -unit-test + +**/*test.go +.git/objects/pack +.github + +# These are directories created by the make process +bin +build +release + +ci +docs +images +release_notes +vagrant diff --git a/Makefile b/Makefile index b2c8717f407..f9b0d939a0d 100644 --- a/Makefile +++ b/Makefile @@ -212,7 +212,9 @@ docker: $(RELEASE_IMAGES:%=%-docker) .PHONY: $(RELEASE_IMAGES:%=%-docker) $(RELEASE_IMAGES:%=%-docker): %-docker: $(BUILD_DIR)/images/%/$(DUMMY) -$(BUILD_DIR)/images/peer/$(DUMMY): BUILD_ARGS=--build-arg GO_TAGS=${GO_TAGS} +$(BUILD_DIR)/images/ccenv/$(DUMMY): BUILD_CONTEXT=images/ccenv +$(BUILD_DIR)/images/baseos/$(DUMMY): BUILD_CONTEXT=images/baseos +$(BUILD_DIR)/images/peer/$(DUMMY): BUILD_ARGS=--build-arg GO_TAGS=${GO_TAGS} $(BUILD_DIR)/images/orderer/$(DUMMY): BUILD_ARGS=--build-arg GO_TAGS=${GO_TAGS} $(BUILD_DIR)/images/%/$(DUMMY): @@ -222,7 +224,7 @@ $(BUILD_DIR)/images/%/$(DUMMY): --build-arg GO_VER=$(GO_VER) \ --build-arg ALPINE_VER=$(ALPINE_VER) \ $(BUILD_ARGS) \ - -t $(DOCKER_NS)/fabric-$* . + -t $(DOCKER_NS)/fabric-$* ./$(BUILD_CONTEXT) docker tag $(DOCKER_NS)/fabric-$* $(DOCKER_NS)/fabric-$*:$(BASE_VERSION) docker tag $(DOCKER_NS)/fabric-$* $(DOCKER_NS)/fabric-$*:$(DOCKER_TAG) @touch $@