Skip to content

Commit

Permalink
[WIP] Precise ccenv composition
Browse files Browse the repository at this point in the history
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 <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Sep 21, 2016
1 parent ac8ab84 commit a0ca796
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ K := $(foreach exec,$(EXECUTABLES),\
SUBDIRS = gotools sdk/node
SUBDIRS:=$(strip $(SUBDIRS))

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

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

%/goshim.tar.bz2: $(GOSHIM_DEPS) Makefile
@echo "Creating $@"
@tar -jhc -C $(GOPATH)/src $(patsubst $(GOPATH)/src/%,%,$(GOSHIM_DEPS)) > $@

.PHONY: protos
protos: gotools
./devenv/compile_protos.sh
Expand Down
3 changes: 2 additions & 1 deletion images/ccenv/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM hyperledger/fabric-src:_TAG_
FROM hyperledger/fabric-baseimage:_BASE_TAG_
COPY bin/* /usr/local/bin/
ADD goshim.tar.bz2 $GOPATH/src/
16 changes: 16 additions & 0 deletions scripts/goListFiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

target=$1

deps=`go list -f '{{ join .Deps "\n" }}' $target`

find $GOPATH/src/$target -type f

for dep in $deps;
do
importpath=$GOPATH/src/$dep
if [ -d $importpath ];
then
find $importpath -type f
fi
done

0 comments on commit a0ca796

Please sign in to comment.