diff options
author | 2019-09-24 10:29:21 +0200 | |
---|---|---|
committer | 2019-09-24 13:29:13 +0200 | |
commit | 7da3e61001d39a36cd7af3e0e34e53d328546838 (patch) | |
tree | 095f7baefde8acedd1523237a2782a81a8d6ca54 /src/main | |
parent | 87a0a7258c0de0473544fb9b6a7df7ecbab8cf9b (diff) |
small, multi-platform (amd64, arm64) images
Modify zookeeper docker container image due to arm64 compatibility
Issue-ID: INT-911
Issue-ID: INT-934
Signed-off-by: Simon Hrabos <simon.hrabos@tieto.com>
Change-Id: I765897a46824c232c1cdde88be86404c0571ae46
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/docker/Dockerfile | 122 |
1 files changed, 70 insertions, 52 deletions
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 7e0d715..30e3a03 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,66 +1,84 @@ -FROM ubuntu:16.04 +# git helper image +FROM alpine:3.9 as githelper +RUN apk add --no-cache git +# Copy APIKeys +RUN git init /zookeeper/gerrit \ + && cd /zookeeper/gerrit \ + && git remote add origin http://gerrit.onap.org/r/dmaap/messagerouter/messageservice.git \ + && git config core.sparsecheckout true \ + && echo "oom-topics/data-zookeeper/*" >> .git/info/sparse-checkout \ + && git pull --depth=1 origin master + +# main image build +FROM docker.io/zookeeper:${zookeeper.dist.version} + +ARG ZK_DIST=zookeeper-${zookeeper.dist.version} ENV ZK_USER=mrzookeeper \ ZK_DATA_DIR=/var/lib/zookeeper/data \ ZK_LOG_DIR=/var/log/zookeeper \ - JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 + ZK_CONF_DIR=/opt/zookeeper/conf \ + ZK_DIST_VER=$ZK_DIST +# passing config path to upstream image +ENV ZOOCFGDIR=$ZK_CONF_DIR -ARG ZK_DIST=zookeeper-3.4.9 +# copy API-keys from githelper +COPY --from=githelper /zookeeper/gerrit/oom-topics /tmp/zookeeper/gerrit/oom-topics -RUN set -x \ - && apt-get update \ - && apt-get install -y openjdk-8-jre-headless wget netcat-openbsd \ - && apt-get install -y git \ - && wget -q "http://archive.apache.org/dist/zookeeper/$ZK_DIST/$ZK_DIST.tar.gz" \ - && wget -q "http://archive.apache.org/dist/zookeeper/$ZK_DIST/$ZK_DIST.tar.gz.asc" \ - && tar -xzf "$ZK_DIST.tar.gz" -C /opt \ - && rm -r "$ZK_DIST.tar.gz" "$ZK_DIST.tar.gz.asc" \ - && ln -s /opt/$ZK_DIST /opt/zookeeper \ - && rm -rf /opt/zookeeper/CHANGES.txt \ - /opt/zookeeper/README.txt \ - /opt/zookeeper/NOTICE.txt \ - /opt/zookeeper/CHANGES.txt \ - /opt/zookeeper/README_packaging.txt \ - /opt/zookeeper/build.xml \ - /opt/zookeeper/config \ - /opt/zookeeper/contrib \ - /opt/zookeeper/dist-maven \ - /opt/zookeeper/docs \ - /opt/zookeeper/ivy.xml \ - /opt/zookeeper/ivysettings.xml \ - /opt/zookeeper/recipes \ - /opt/zookeeper/src \ - /opt/zookeeper/$ZK_DIST.jar.asc \ - /opt/zookeeper/$ZK_DIST.jar.md5 \ - /opt/zookeeper/$ZK_DIST.jar.sha1 \ - && apt-get autoremove -y wget \ - && rm -rf /var/lib/apt/lists/* +# Create required directories and configure file system ownership +# for necessary directories and symlink the distribution as a user executable +# and remove unecessary files +RUN mkdir -p \ + /opt \ + /usr/etc \ + /usr/share/zookeeper \ + $ZK_DATA_DIR \ + $ZK_LOG_DIR \ + && ln -snf /$ZK_DIST_VER/ /opt/zookeeper \ + && ln -snf /opt/zookeeper/conf/ /usr/etc/zookeeper \ + && ln -snf /opt/zookeeper/bin/* /usr/bin \ + && ln -snf /opt/zookeeper/$ZK_DIST_VER.jar /usr/share/zookeeper \ + && ln -snf /opt/zookeeper/lib/* /usr/share/zookeeper \ + && rm -rf \ + /conf \ + /home/zookeeper \ + /docker-entrypoint.sh \ + /opt/zookeeper/CHANGES.txt \ + /opt/zookeeper/README.txt \ + /opt/zookeeper/NOTICE.txt \ + /opt/zookeeper/CHANGES.txt \ + /opt/zookeeper/README_packaging.txt \ + /opt/zookeeper/build.xml \ + /opt/zookeeper/config \ + /opt/zookeeper/contrib \ + /opt/zookeeper/dist-maven \ + /opt/zookeeper/docs \ + /opt/zookeeper/ivy.xml \ + /opt/zookeeper/ivysettings.xml \ + /opt/zookeeper/recipes \ + /opt/zookeeper/src \ + /opt/zookeeper/$ZK_DIST_VER.jar.asc \ + /opt/zookeeper/$ZK_DIST_VER.jar.md5 \ + /opt/zookeeper/$ZK_DIST_VER.jar.sha1 # Copy configuration generator script to bin COPY scripts /opt/zookeeper/bin/ - -# Copy APIKeys -RUN git clone -b master --single-branch http://gerrit.onap.org/r/dmaap/messagerouter/messageservice.git /tmp/zookeeper/gerrit - -# Create a user for the zookeeper process and configure file system ownership -# for necessary directories and symlink the distribution as a user executable -RUN set -x \ - && mkdir -p $ZK_DATA_DIR $ZK_LOG_DIR /usr/share/zookeeper /tmp/zookeeper /usr/etc/ \ - && ln -s /opt/zookeeper/conf/ /usr/etc/zookeeper \ - && ln -s /opt/zookeeper/bin/* /usr/bin \ - && ln -s /opt/zookeeper/$ZK_DIST.jar /usr/share/zookeeper/ \ -&& ln -s /opt/zookeeper/lib/* /usr/share/zookeeper - RUN chmod -R 777 /opt/zookeeper/bin -ENTRYPOINT /opt/zookeeper/bin/start-zookeeper.sh -EXPOSE 2181 2888 3888 -RUN useradd $ZK_USER \ - && [ `id -u $ZK_USER` -eq 1000 ] \ - && [ `id -g $ZK_USER` -eq 1000 ] \ - && chown -R $ZK_USER:$ZK_USER /opt/$ZK_DIST/ /opt/zookeeper/ /var/lib/ /var/log/ /tmp/zookeeper/ +# delete zookeeper user from upsteram image and create custom user instead +RUN deluser zookeeper > /dev/null 2>&1 \ + && { addgroup -S -g 1000 $ZK_USER > /dev/null 2>&1 && adduser -S -D -G $ZK_USER -u 1000 $ZK_USER > /dev/null 2>&1; } \ + || { groupadd -r -g 1000 $ZK_USER && useradd -r -M -g 1000 -u 1000 $ZK_USER; } \ + && chown -R $ZK_USER:$ZK_USER \ + /opt/zookeeper \ + /tmp/zookeeper \ + /var/lib/zookeeper \ + /var/log/zookeeper \ + $ZK_CONF_DIR \ + $ZK_DATA_DIR \ + $ZK_LOG_DIR +EXPOSE 2181 2888 3888 USER $ZK_USER - - +ENTRYPOINT ["/opt/zookeeper/bin/start-zookeeper.sh"]
\ No newline at end of file |