sunil unnava | 97d04ee | 2018-11-20 15:29:12 -0500 | [diff] [blame] | 1 | FROM ubuntu:16.04 |
| 2 | |
sunil unnava | e68d446 | 2018-11-21 21:58:13 -0500 | [diff] [blame] | 3 | ENV ZK_USER=root \ |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 4 | ZK_DATA_DIR=/var/lib/zookeeper/data \ |
| 5 | ZK_DATA_LOG_DIR=/var/lib/zookeeper/log \ |
| 6 | ZK_LOG_DIR=/var/log/zookeeper \ |
| 7 | JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 8 | |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 9 | ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 10 | ARG ZK_DIST=zookeeper-3.4.10 |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 11 | |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 12 | RUN set -x \ |
| 13 | && apt-get update \ |
| 14 | && apt-get install -y openjdk-8-jre-headless wget netcat-openbsd \ |
sunil unnava | 97d04ee | 2018-11-20 15:29:12 -0500 | [diff] [blame] | 15 | && wget -q "http://www.apache.org/dist/zookeeper/$ZK_DIST/$ZK_DIST.tar.gz" \ |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 16 | && wget -q "http://www.apache.org/dist/zookeeper/$ZK_DIST/$ZK_DIST.tar.gz.asc" \ |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 17 | && export GNUPGHOME="$(mktemp -d)" \ |
| 18 | && gpg --keyserver ha.pool.sks-keyservers.net --recv-key "$GPG_KEY" \ |
| 19 | && gpg --batch --verify "$ZK_DIST.tar.gz.asc" "$ZK_DIST.tar.gz" \ |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 20 | && tar -xzf "$ZK_DIST.tar.gz" -C /opt \ |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 21 | && rm -r "$GNUPGHOME" "$ZK_DIST.tar.gz" "$ZK_DIST.tar.gz.asc" \ |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 22 | && ln -s /opt/$ZK_DIST /opt/zookeeper \ |
| 23 | && rm -rf /opt/zookeeper/CHANGES.txt \ |
| 24 | /opt/zookeeper/README.txt \ |
| 25 | /opt/zookeeper/NOTICE.txt \ |
| 26 | /opt/zookeeper/CHANGES.txt \ |
| 27 | /opt/zookeeper/README_packaging.txt \ |
| 28 | /opt/zookeeper/build.xml \ |
| 29 | /opt/zookeeper/config \ |
| 30 | /opt/zookeeper/contrib \ |
| 31 | /opt/zookeeper/dist-maven \ |
| 32 | /opt/zookeeper/docs \ |
| 33 | /opt/zookeeper/ivy.xml \ |
| 34 | /opt/zookeeper/ivysettings.xml \ |
| 35 | /opt/zookeeper/recipes \ |
| 36 | /opt/zookeeper/src \ |
| 37 | /opt/zookeeper/$ZK_DIST.jar.asc \ |
| 38 | /opt/zookeeper/$ZK_DIST.jar.md5 \ |
| 39 | /opt/zookeeper/$ZK_DIST.jar.sha1 \ |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 40 | && apt-get autoremove -y wget \ |
| 41 | && rm -rf /var/lib/apt/lists/* |
sunil unnava | 97d04ee | 2018-11-20 15:29:12 -0500 | [diff] [blame] | 42 | |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 43 | # Copy configuration generator script to bin |
sunil unnava | 1fd255a | 2018-11-21 19:40:03 -0500 | [diff] [blame] | 44 | COPY scripts /opt/zookeeper/bin/ |
sunil unnava | 94d2769 | 2018-11-26 09:37:28 -0500 | [diff] [blame^] | 45 | |
sunil unnava | 5e3d91f | 2018-11-20 14:43:42 -0500 | [diff] [blame] | 46 | |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 47 | # Create a user for the zookeeper process and configure file system ownership |
| 48 | # for necessary directories and symlink the distribution as a user executable |
| 49 | RUN set -x \ |
sunil unnava | 94d2769 | 2018-11-26 09:37:28 -0500 | [diff] [blame^] | 50 | && useradd $ZK_USER \ |
sunil unnava | 61490fb | 2018-11-21 19:16:02 -0500 | [diff] [blame] | 51 | && [ `id -u $ZK_USER` -eq 1000 ] \ |
| 52 | && [ `id -g $ZK_USER` -eq 1000 ] \ |
| 53 | && mkdir -p $ZK_DATA_DIR $ZK_DATA_LOG_DIR $ZK_LOG_DIR /usr/share/zookeeper /tmp/zookeeper /usr/etc/ \ |
| 54 | && chown -R "$ZK_USER:$ZK_USER" /opt/$ZK_DIST $ZK_DATA_DIR $ZK_LOG_DIR $ZK_DATA_LOG_DIR /tmp/zookeeper \ |
| 55 | && ln -s /opt/zookeeper/conf/ /usr/etc/zookeeper \ |
| 56 | && ln -s /opt/zookeeper/bin/* /usr/bin \ |
| 57 | && ln -s /opt/zookeeper/$ZK_DIST.jar /usr/share/zookeeper/ \ |
sunil unnava | e68d446 | 2018-11-21 21:58:13 -0500 | [diff] [blame] | 58 | && ln -s /opt/zookeeper/lib/* /usr/share/zookeeper |
| 59 | |
sunil unnava | 1e6634c | 2018-11-23 16:40:05 -0500 | [diff] [blame] | 60 | |
| 61 | RUN chown -R $ZK_USER:$ZK_USER /var/lib/zookeeper/data/myid |
| 62 | RUN chown -R $ZK_USER:$ZK_USER /opt/zookeeper/bin/start-zookeeper.sh |
sunil unnava | a828b81 | 2018-11-23 17:02:12 -0500 | [diff] [blame] | 63 | RUN chown -R $ZK_USER:$ZK_USER /opt/zookeeper/bin/zookeeper-metrics.sh |
sunil unnava | 1e6634c | 2018-11-23 16:40:05 -0500 | [diff] [blame] | 64 | RUN chown -R $ZK_USER:$ZK_USER /opt/zookeeper/bin/zookeeper-ready.sh |