1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-25 02:04:06 +02:00

add zookeeper

This commit is contained in:
kev 2017-09-13 17:31:46 +08:00
parent 9e81fb7eb0
commit a02f8253ab
7 changed files with 163 additions and 0 deletions

View File

@ -263,6 +263,7 @@ A collection of delicious docker recipes.
- [x] standalone-firefox
- [x] tutum/builder
- [x] wekanteam/wekan
- [x] zookeeper
## auto-completion

40
zookeeper/README.md Normal file
View File

@ -0,0 +1,40 @@
zookeeper
=========
![](http://zookeeper.apache.org/images/zookeeper_small.gif)
Apache [ZooKeeper][1] is an effort to develop and maintain an open-source server
which enables highly reliable distributed coordination.
## docker-compose.yml
```yaml
zookeeper:
image: zookeeper
ports:
- "2181:2181"
volumes:
- ./data:/data
- ./datalog:/datalog
restart: always
```
## Standalone Mode
```bash
$ docker-compose up -d
$ docker-compose exec zookeeper zkCli.sh
>>> help
>>> create /hello world
>>> get /hello
>>> delete /hello
>>> quit
```
Click [this][2] to learn more.
## Cluster Mode [TODO]
[1]: http://zookeeper.apache.org/
[2]: https://zookeeper.apache.org/doc/trunk/zookeeperStarted.html

59
zookeeper/arm/Dockerfile Normal file
View File

@ -0,0 +1,59 @@
#
# Dockerfile for zookeeper-arm
#
FROM easypi/alpine-arm
MAINTAINER EasyPi Software Foundation
# Install required packages
RUN apk add --no-cache \
bash \
openjdk8-jre \
su-exec
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 \
ZOO_MAX_CLIENT_CNXNS=60
# Add a user and make dirs
RUN set -ex; \
adduser -D "$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.10
# Download Apache Zookeeper, verify its PGP signature, untar and clean up
RUN set -ex; \
apk add --no-cache --virtual .build-deps \
gnupg wget; \
wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz"; \
wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz.asc"; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --keyserver ha.pool.sks-keyservers.net --recv-key "$GPG_KEY" || \
gpg --keyserver pgp.mit.edu --recv-keys "$GPG_KEY" || \
gpg --keyserver keyserver.pgp.com --recv-keys "$GPG_KEY"; \
gpg --batch --verify "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME.tar.gz"; \
tar -xzf "$DISTRO_NAME.tar.gz"; \
mv "$DISTRO_NAME/conf/"* "$ZOO_CONF_DIR"; \
rm -rf "$GNUPGHOME" "$DISTRO_NAME.tar.gz" "$DISTRO_NAME.tar.gz.asc"; \
apk del .build-deps
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 docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zkServer.sh", "start-foreground"]

View File

@ -0,0 +1,12 @@
zookeeper:
image: easypi/zookeeper-arm
volumes:
- ./data:/data
- ./datalog:/datalog
environment:
- ZOO_MY_ID=1
- ZOO_SERVERS=server.1=192.168.1.106:2888:3888
server.2=192.168.1.107:2888:3888
server.3=192.168.1.108:2888:3888
net: host
restart: always

View File

@ -0,0 +1,8 @@
zookeeper:
image: easypi/zookeeper-arm
ports:
- "2181:2181"
volumes:
- ./data:/data
- ./datalog:/datalog
restart: always

View File

@ -0,0 +1,35 @@
#!/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"
echo "maxClientCnxns=$ZOO_MAX_CLIENT_CNXNS" >> "$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 "$@"

View File

@ -0,0 +1,8 @@
zookeeper:
image: zookeeper
ports:
- "2181:2181"
volumes:
- ./data:/data
- ./datalog:/datalog
restart: always