Skip to content

Commit

Permalink
[FAB-1657] enable zookeeper on POWER & s390x
Browse files Browse the repository at this point in the history
Use platform specific testenv image for POWER and s390x
as base image inorder to build zookeeper, instead of using x86_64
specific zookeeper image for orderer kafka behave tests

Change-Id: I3a42781234558581e14dcb2d1aabbc5593454852
Signed-off-by: Krishna Harsha Voora <krishvoor@in.ibm.com>
  • Loading branch information
krishvoor authored and Luis Sanchez committed Jan 20, 2017
1 parent 18b4089 commit fc5291f
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 9 deletions.
3 changes: 2 additions & 1 deletion 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
IMAGES = peer orderer ccenv javaenv testenv runtime zookeeper

pkgmap.peer := $(PKGNAME)/peer
pkgmap.orderer := $(PKGNAME)/orderer
Expand Down Expand Up @@ -191,6 +191,7 @@ build/image/orderer/payload: build/docker/bin/orderer \
orderer/orderer.yaml
build/image/testenv/payload: build/gotools.tar.bz2
build/image/runtime/payload: build/docker/busybox
build/image/zookeeper/payload: images/zookeeper/docker-entrypoint.sh

build/image/%/payload:
mkdir -p $@
Expand Down
3 changes: 1 addition & 2 deletions bddtests/environments/kafka/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '2'
services:
zookeeper:
# Offical Apache ZooKeeper image. See https://hub.docker.com/_/zookeeper/
image: zookeeper:3.4.9
image: hyperledger/fabric-zookeeper

kafka:
build: .
Expand Down
3 changes: 1 addition & 2 deletions bddtests/environments/orderer-1-kafka-1/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '2'
services:
zookeeper:
# Offical Apache ZooKeeper image. See https://hub.docker.com/_/zookeeper/
image: zookeeper:3.4.9
image: hyperledger/fabric-zookeeper

orderer0:
image: hyperledger/fabric-orderer
Expand Down
3 changes: 1 addition & 2 deletions bddtests/environments/orderer-1-kafka-3/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '2'
services:
zookeeper:
# Offical Apache ZooKeeper image. See https://hub.docker.com/_/zookeeper/
image: zookeeper:3.4.9
image: hyperledger/fabric-zookeeper

orderer0:
image: hyperledger/fabric-orderer
Expand Down
3 changes: 1 addition & 2 deletions bddtests/environments/orderer-n-kafka-n/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '2'
services:
zookeeper:
# Offical Apache ZooKeeper image. See https://hub.docker.com/_/zookeeper/
image: zookeeper:3.4.9
image: hyperledger/fabric-zookeeper

orderer:
build: ./orderer
Expand Down
47 changes: 47 additions & 0 deletions images/zookeeper/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM hyperledger/fabric-baseimage:_BASE_TAG_
# Based on https://github.com/31z4/zookeeper-docker/blob/master/3.4.9/Dockerfile

# Install su-exec
RUN set -x \
&& git clone https://github.com/ncopa/su-exec /tmp/su-exec/ \
&& cd /tmp/su-exec \
&& make all \
&& cp su-exec /usr/bin/

ENV ZOO_USER=zookeeper \
ZOO_CONF_DIR=/conf \
ZOO_DATA_DIR=/data \
ZOO_DATA_LOG_DIR=/datalog \
ZOO_PORT=2181 \
ZOO_TICK_TIME=2000 \
ZOO_INIT_LIMIT=5 \
ZOO_SYNC_LIMIT=2

# Add a user and make dirs
RUN set -x \
&& useradd "$ZOO_USER" \
&& mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR" \
&& chown "$ZOO_USER:$ZOO_USER" "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR"

ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D
ARG DISTRO_NAME=zookeeper-3.4.9

# Download Apache Zookeeper, verify its PGP signature, untar and clean up
RUN set -x \
&& cd / \
&& wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz" \
&& tar -xzf "$DISTRO_NAME.tar.gz" \
&& mv "$DISTRO_NAME/conf/"* "$ZOO_CONF_DIR" \
&& rm -r "$DISTRO_NAME.tar.gz"

WORKDIR $DISTRO_NAME
VOLUME ["$ZOO_DATA_DIR", "$ZOO_DATA_LOG_DIR"]

EXPOSE $ZOO_PORT 2888 3888

ENV PATH=$PATH:/$DISTRO_NAME/bin \
ZOOCFGDIR=$ZOO_CONF_DIR

COPY payload/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zkServer.sh", "start-foreground"]
33 changes: 33 additions & 0 deletions images/zookeeper/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -e

# Allow the container to be started with `--user`
if [ "$1" = 'zkServer.sh' -a "$(id -u)" = '0' ]; then
chown -R "$ZOO_USER" "$ZOO_DATA_DIR" "$ZOO_DATA_LOG_DIR"
exec su-exec "$ZOO_USER" "$0" "$@"
fi

# Generate the config only if it doesn't exist
if [ ! -f "$ZOO_CONF_DIR/zoo.cfg" ]; then
CONFIG="$ZOO_CONF_DIR/zoo.cfg"

echo "clientPort=$ZOO_PORT" >> "$CONFIG"
echo "dataDir=$ZOO_DATA_DIR" >> "$CONFIG"
echo "dataLogDir=$ZOO_DATA_LOG_DIR" >> "$CONFIG"

echo "tickTime=$ZOO_TICK_TIME" >> "$CONFIG"
echo "initLimit=$ZOO_INIT_LIMIT" >> "$CONFIG"
echo "syncLimit=$ZOO_SYNC_LIMIT" >> "$CONFIG"

for server in $ZOO_SERVERS; do
echo "$server" >> "$CONFIG"
done
fi

# Write myid only if it doesn't exist
if [ ! -f "$ZOO_DATA_DIR/myid" ]; then
echo "${ZOO_MY_ID:-1}" > "$ZOO_DATA_DIR/myid"
fi

exec "$@"

0 comments on commit fc5291f

Please sign in to comment.