Skip to content

Commit 20c74ea

Browse files
committed
Use buildenv image for linter/protos
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 <[email protected]>
1 parent 9c39adb commit 20c74ea

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

Makefile

+11-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
6464
PROTOS = $(shell git ls-files *.proto | grep -v vendor)
6565
MSP_SAMPLECONFIG = $(shell git ls-files msp/sampleconfig/*.pem)
6666
PROJECT_FILES = $(shell git ls-files)
67-
IMAGES = peer orderer ccenv javaenv testenv zookeeper kafka
67+
IMAGES = peer orderer ccenv javaenv buildenv testenv zookeeper kafka
6868

6969
pkgmap.peer := $(PKGNAME)/peer
7070
pkgmap.orderer := $(PKGNAME)/orderer
@@ -96,6 +96,9 @@ peer-docker: build/image/peer/$(DUMMY)
9696
orderer: build/bin/orderer
9797
orderer-docker: build/image/orderer/$(DUMMY)
9898

99+
buildenv: build/image/buildenv/$(DUMMY)
100+
101+
build/image/testenv/$(DUMMY): build/image/buildenv/$(DUMMY)
99102
testenv: build/image/testenv/$(DUMMY)
100103

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

121-
linter: testenv
124+
linter: buildenv
122125
@echo "LINT: Running code checks.."
123-
@$(DRUN) hyperledger/fabric-testenv:$(DOCKER_TAG) ./scripts/golinter.sh
126+
@$(DRUN) hyperledger/fabric-buildenv:$(DOCKER_TAG) ./scripts/golinter.sh
124127

125128
%/chaintool: Makefile
126129
@echo "Installing chaintool"
@@ -180,8 +183,9 @@ build/image/orderer/payload: build/docker/bin/orderer \
180183
build/msp-sampleconfig.tar.bz2 \
181184
orderer/orderer.yaml \
182185
common/configtx/tool/genesis.yaml
183-
build/image/testenv/payload: build/gotools.tar.bz2 \
184-
build/docker/bin/orderer \
186+
build/image/buildenv/payload: build/gotools.tar.bz2 \
187+
build/docker/gotools/bin/protoc-gen-go
188+
build/image/testenv/payload: build/docker/bin/orderer \
185189
orderer/orderer.yaml \
186190
common/configtx/tool/genesis.yaml \
187191
build/docker/bin/peer \
@@ -227,8 +231,8 @@ build/%.tar.bz2:
227231
@tar -jc $^ > $@
228232

229233
.PHONY: protos
230-
protos: testenv
231-
@$(DRUN) hyperledger/fabric-testenv:$(DOCKER_TAG) ./scripts/compile_protos.sh
234+
protos: buildenv
235+
@$(DRUN) hyperledger/fabric-buildenv:$(DOCKER_TAG) ./scripts/compile_protos.sh
232236

233237
%-docker-clean:
234238
$(eval TARGET = ${patsubst %-docker-clean,%,${@}})

images/buildenv/Dockerfile.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM hyperledger/fabric-baseimage:_BASE_TAG_
2+
COPY payload/protoc-gen-go /usr/local/bin/
3+
ADD payload/gotools.tar.bz2 /usr/local/bin/

images/testenv/Dockerfile.in

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM hyperledger/fabric-baseimage:_BASE_TAG_
1+
FROM hyperledger/fabric-buildenv:_TAG_
22

33
# fabric configuration locations
44
ENV PEER_CFG_PATH /etc/hyperledger/fabric
@@ -10,16 +10,12 @@ RUN mkdir -p \
1010
$ORDERER_CFG_PATH \
1111
/var/hyperledger/production
1212

13-
# install gotools
14-
ADD payload/gotools.tar.bz2 /usr/local/bin/
15-
1613
# fabric configuration files
1714
COPY payload/orderer.yaml $ORDERER_CFG_PATH
1815
COPY payload/genesis.yaml $ORDERER_CFG_PATH
1916
COPY payload/core.yaml $PEER_CFG_PATH
2017
ADD payload/msp-sampleconfig.tar.bz2 $PEER_CFG_PATH
2118

22-
2319
# fabric binaries
2420
COPY payload/orderer /usr/local/bin
2521
COPY payload/peer /usr/local/bin

0 commit comments

Comments
 (0)