Skip to content

Commit

Permalink
Use buildenv image for linter/protos
Browse files Browse the repository at this point in the history
At one point in time, "testenv" was used for basic build-time
processes such as linter, protos, and unit-tests.  Overtime, the
requirements for unit-testing grew and more dependencies were added.
This had the side-effect of requiring all prerequisites for unit-testing
be met for the other uses such as "make protos".  This led to a
chicken-egg scenario when certain dependencies required the protos
to be updated before they could be built, but the proto compilation
required them to be built before it could run.

This is clearly not correct.

We fix this by making the image contruction more fine-grained.  We split
the basic functionality of "testenv" out into "buildenv".  We then
allow the linter/protos process and the testenv image to consume buildenv.

Change-Id: I5db05bac649c2fefe73b19ec06e44efe3d2b42fa
Signed-off-by: Gregory Haskins <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Feb 14, 2017
1 parent 9c39adb commit 20c74ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
PROTOS = $(shell git ls-files *.proto | grep -v vendor)
MSP_SAMPLECONFIG = $(shell git ls-files msp/sampleconfig/*.pem)
PROJECT_FILES = $(shell git ls-files)
IMAGES = peer orderer ccenv javaenv testenv zookeeper kafka
IMAGES = peer orderer ccenv javaenv buildenv testenv zookeeper kafka

pkgmap.peer := $(PKGNAME)/peer
pkgmap.orderer := $(PKGNAME)/orderer
Expand Down Expand Up @@ -96,6 +96,9 @@ peer-docker: build/image/peer/$(DUMMY)
orderer: build/bin/orderer
orderer-docker: build/image/orderer/$(DUMMY)

buildenv: build/image/buildenv/$(DUMMY)

build/image/testenv/$(DUMMY): build/image/buildenv/$(DUMMY)
testenv: build/image/testenv/$(DUMMY)

unit-test: peer-docker testenv
Expand All @@ -118,9 +121,9 @@ behave: behave-deps
@echo "Running behave tests"
@cd bddtests; behave $(BEHAVE_OPTS)

linter: testenv
linter: buildenv
@echo "LINT: Running code checks.."
@$(DRUN) hyperledger/fabric-testenv:$(DOCKER_TAG) ./scripts/golinter.sh
@$(DRUN) hyperledger/fabric-buildenv:$(DOCKER_TAG) ./scripts/golinter.sh

%/chaintool: Makefile
@echo "Installing chaintool"
Expand Down Expand Up @@ -180,8 +183,9 @@ build/image/orderer/payload: build/docker/bin/orderer \
build/msp-sampleconfig.tar.bz2 \
orderer/orderer.yaml \
common/configtx/tool/genesis.yaml
build/image/testenv/payload: build/gotools.tar.bz2 \
build/docker/bin/orderer \
build/image/buildenv/payload: build/gotools.tar.bz2 \
build/docker/gotools/bin/protoc-gen-go
build/image/testenv/payload: build/docker/bin/orderer \
orderer/orderer.yaml \
common/configtx/tool/genesis.yaml \
build/docker/bin/peer \
Expand Down Expand Up @@ -227,8 +231,8 @@ build/%.tar.bz2:
@tar -jc $^ > $@

.PHONY: protos
protos: testenv
@$(DRUN) hyperledger/fabric-testenv:$(DOCKER_TAG) ./scripts/compile_protos.sh
protos: buildenv
@$(DRUN) hyperledger/fabric-buildenv:$(DOCKER_TAG) ./scripts/compile_protos.sh

%-docker-clean:
$(eval TARGET = ${patsubst %-docker-clean,%,${@}})
Expand Down
3 changes: 3 additions & 0 deletions images/buildenv/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM hyperledger/fabric-baseimage:_BASE_TAG_
COPY payload/protoc-gen-go /usr/local/bin/
ADD payload/gotools.tar.bz2 /usr/local/bin/
6 changes: 1 addition & 5 deletions images/testenv/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/fabric-baseimage:_BASE_TAG_
FROM hyperledger/fabric-buildenv:_TAG_

# fabric configuration locations
ENV PEER_CFG_PATH /etc/hyperledger/fabric
Expand All @@ -10,16 +10,12 @@ RUN mkdir -p \
$ORDERER_CFG_PATH \
/var/hyperledger/production

# install gotools
ADD payload/gotools.tar.bz2 /usr/local/bin/

# fabric configuration files
COPY payload/orderer.yaml $ORDERER_CFG_PATH
COPY payload/genesis.yaml $ORDERER_CFG_PATH
COPY payload/core.yaml $PEER_CFG_PATH
ADD payload/msp-sampleconfig.tar.bz2 $PEER_CFG_PATH


# fabric binaries
COPY payload/orderer /usr/local/bin
COPY payload/peer /usr/local/bin
Expand Down

0 comments on commit 20c74ea

Please sign in to comment.