Skip to content

Commit

Permalink
[FAB-1780] Cleanup kafka docker image build
Browse files Browse the repository at this point in the history
 - moved image from bddtests/environments/ to images/
 - cleaned up Makefile
 - configured compose environments to use image

Change-Id: I08caff43c947d8f3b15f69775f578556e847312b
Signed-off-by: Luis Sanchez <sanchezl@us.ibm.com>
  • Loading branch information
Luis Sanchez committed Jan 20, 2017
1 parent f91dace commit 0a29bcf
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 22 deletions.
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PROTOS = $(shell git ls-files *.proto | grep -v vendor)
MSP_SAMPLECONFIG = $(shell git ls-files msp/sampleconfig/*.pem)
GENESIS_SAMPLECONFIG = $(shell git ls-files common/configtx/test/*.template)
PROJECT_FILES = $(shell git ls-files)
IMAGES = peer orderer ccenv javaenv testenv runtime zookeeper
IMAGES = peer orderer ccenv javaenv testenv runtime zookeeper kafka

pkgmap.peer := $(PKGNAME)/peer
pkgmap.orderer := $(PKGNAME)/orderer
Expand Down Expand Up @@ -106,13 +106,11 @@ docker: $(patsubst %,build/image/%/$(DUMMY), $(IMAGES))
native: peer orderer

BEHAVE_ENVIRONMENTS = kafka orderer-1-kafka-1 orderer-1-kafka-3
.PHONY: behave-environments $(BEHAVE_ENVIRONMENTS)
behave-environments: $(BEHAVE_ENVIRONMENTS)
$(BEHAVE_ENVIRONMENTS):
@echo "# Generated from Dockerfile.in. DO NOT EDIT!" > bddtests/environments/kafka/Dockerfile
@cat bddtests/environments/kafka/Dockerfile.in | \
sed -e "s|_DOCKER_TAG_|$(DOCKER_TAG)|" >> bddtests/environments/kafka/Dockerfile
@docker-compose --file bddtests/environments/$@/docker-compose.yml build
BEHAVE_ENVIRONMENT_TARGETS = $(patsubst %,bddtests/environments/%, $(BEHAVE_ENVIRONMENTS))
.PHONY: behave-environments $(BEHAVE_ENVIRONMENT_TARGETS)
behave-environments: $(BEHAVE_ENVIRONMENT_TARGETS)
$(BEHAVE_ENVIRONMENT_TARGETS):
@docker-compose --file $@/docker-compose.yml build

behave-deps: docker peer build/bin/block-listener behave-environments
behave: behave-deps
Expand Down Expand Up @@ -197,18 +195,21 @@ build/image/testenv/payload: build/gotools.tar.bz2 \
build/msp-sampleconfig.tar.bz2
build/image/runtime/payload: build/docker/busybox
build/image/zookeeper/payload: images/zookeeper/docker-entrypoint.sh
build/image/kafka/payload: images/kafka/docker-entrypoint.sh

build/image/%/payload:
mkdir -p $@
cp $^ $@

build/image/%/$(DUMMY): Makefile build/image/%/payload
$(eval TARGET = ${patsubst build/image/%/$(DUMMY),%,${@}})
@echo "Building docker $(TARGET)-image"
@cat images/$(TARGET)/Dockerfile.in \
build/image/%/Dockerfile: images/%/Dockerfile.in
@cat $< \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
> $@

build/image/%/$(DUMMY): Makefile build/image/%/payload build/image/%/Dockerfile
$(eval TARGET = ${patsubst build/image/%/$(DUMMY),%,${@}})
@echo "Building docker $(TARGET)-image"
$(DBUILD) -t $(PROJECT_NAME)-$(TARGET) $(@D)
docker tag $(PROJECT_NAME)-$(TARGET) $(PROJECT_NAME)-$(TARGET):$(DOCKER_TAG)
@touch $@
Expand Down
1 change: 0 additions & 1 deletion bddtests/environments/kafka/.dockerignore

This file was deleted.

15 changes: 15 additions & 0 deletions bddtests/environments/kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ Stopping kafka_kafka_1 ... done
Stopping kafka_zookeeper_1 ... done
$
```
#### Cleanup
Use `docker-compose down` instead of `docker-compose rm` when cleaning up, so that the network is purged in addition to the containers.
```console
$ docker-compose down
Stopping kafka_kafka_3 ... done
Stopping kafka_kafka_2 ... done
Stopping kafka_kafka_1 ... done
Stopping kafka_zookeeper_1 ... done
Removing kafka_kafka_3 ... done
Removing kafka_kafka_2 ... done
Removing kafka_kafka_1 ... done
Removing kafka_zookeeper_1 ... done
Removing network kafka_default
$
```
## Configuration
Edit the [`docker-compose.yml`](docker-compose.yml) file to configure.
### server.properties
Expand Down
2 changes: 1 addition & 1 deletion bddtests/environments/kafka/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: hyperledger/fabric-zookeeper

kafka:
build: .
image: hyperledger/fabric-kafka
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion bddtests/environments/orderer-1-kafka-1/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- kafka0

kafka0:
build: ../kafka
image: hyperledger/fabric-kafka
environment:
KAFKA_BROKER_ID: 0
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Expand Down
6 changes: 3 additions & 3 deletions bddtests/environments/orderer-1-kafka-3/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- kafka2

kafka0:
build: ../kafka
image: hyperledger/fabric-kafka
environment:
KAFKA_BROKER_ID: 0
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Expand All @@ -28,7 +28,7 @@ services:
- zookeeper

kafka1:
build: ../kafka
image: hyperledger/fabric-kafka
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Expand All @@ -37,7 +37,7 @@ services:
- zookeeper

kafka2:
build: ../kafka
image: hyperledger/fabric-kafka
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
Expand Down
2 changes: 1 addition & 1 deletion bddtests/environments/orderer-n-kafka-n/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- kafka

kafka:
build: ../kafka
image: hyperledger/fabric-kafka
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
depends_on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/fabric-testenv:_DOCKER_TAG_
FROM hyperledger/fabric-baseimage:_BASE_TAG_

ENV SCALA_VERSION=2.11 \
KAFKA_VERSION=0.9.0.1 \
Expand All @@ -10,7 +10,7 @@ RUN curl -fSL "http://www-us.apache.org/dist/kafka/0.9.0.1/kafka_${SCALA_VERSION
&& mv /opt/kafka_"$SCALA_VERSION"-"$KAFKA_VERSION" /opt/kafka \
&& rm kafka_"$SCALA_VERSION"-"$KAFKA_VERSION".tgz

ADD docker-entrypoint.sh /docker-entrypoint.sh
ADD payload/docker-entrypoint.sh /docker-entrypoint.sh

EXPOSE 9092

Expand Down
File renamed without changes.

0 comments on commit 0a29bcf

Please sign in to comment.