Skip to content

Commit a0ca796

Browse files
committed
[WIP] Precise ccenv composition
Right now, ccenv is stuffed with the full fabric.git src, when its intended to only carry just enough bits to build a chaincode application. This minimally entails the golang shim and any direct or transitive deps. It may include others in the future. Change-Id: I01947870264b99959219160978449f3b97bc4a68 Signed-off-by: Greg Haskins <[email protected]>
1 parent ac8ab84 commit a0ca796

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ K := $(foreach exec,$(EXECUTABLES),\
6666
SUBDIRS = gotools sdk/node
6767
SUBDIRS:=$(strip $(SUBDIRS))
6868

69+
GOSHIM_DEPS = $(shell ./scripts/goListFiles.sh github.com/hyperledger/fabric/core/chaincode/shim | sort | uniq)
6970
JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
7071
PROJECT_FILES = $(shell git ls-files)
7172
IMAGES = src ccenv peer membersrvc javaenv
@@ -192,7 +193,7 @@ build/image/src/.dummy: $(PROJECT_FILES)
192193
@touch $@
193194

194195
# Special override for ccenv-image (chaincode-environment)
195-
build/image/ccenv/.dummy: build/image/src/.dummy build/image/ccenv/bin/protoc-gen-go build/image/ccenv/bin/chaintool Makefile
196+
build/image/ccenv/.dummy: build/image/ccenv/bin/protoc-gen-go build/image/ccenv/bin/chaintool build/image/ccenv/goshim.tar.bz2 Makefile
196197
@echo "Building docker ccenv-image"
197198
@cat images/ccenv/Dockerfile.in \
198199
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
@@ -234,6 +235,10 @@ build/image/%/.dummy: build/image/src/.dummy build/docker/bin/%
234235
docker tag $(PROJECT_NAME)-$(TARGET) $(PROJECT_NAME)-$(TARGET):$(DOCKER_TAG)
235236
@touch $@
236237

238+
%/goshim.tar.bz2: $(GOSHIM_DEPS) Makefile
239+
@echo "Creating $@"
240+
@tar -jhc -C $(GOPATH)/src $(patsubst $(GOPATH)/src/%,%,$(GOSHIM_DEPS)) > $@
241+
237242
.PHONY: protos
238243
protos: gotools
239244
./devenv/compile_protos.sh

images/ccenv/Dockerfile.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
FROM hyperledger/fabric-src:_TAG_
1+
FROM hyperledger/fabric-baseimage:_BASE_TAG_
22
COPY bin/* /usr/local/bin/
3+
ADD goshim.tar.bz2 $GOPATH/src/

scripts/goListFiles.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
target=$1
4+
5+
deps=`go list -f '{{ join .Deps "\n" }}' $target`
6+
7+
find $GOPATH/src/$target -type f
8+
9+
for dep in $deps;
10+
do
11+
importpath=$GOPATH/src/$dep
12+
if [ -d $importpath ];
13+
then
14+
find $importpath -type f
15+
fi
16+
done

0 commit comments

Comments
 (0)