From 7da3e61001d39a36cd7af3e0e34e53d328546838 Mon Sep 17 00:00:00 2001 From: Simon Hrabos Date: Tue, 24 Sep 2019 10:29:21 +0200 Subject: 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 Change-Id: I765897a46824c232c1cdde88be86404c0571ae46 --- pom.xml | 132 +++++++++++++++------------------------------ src/main/docker/Dockerfile | 122 +++++++++++++++++++++++------------------ 2 files changed, 113 insertions(+), 141 deletions(-) diff --git a/pom.xml b/pom.xml index 8ad6cfa..70365bd 100644 --- a/pom.xml +++ b/pom.xml @@ -104,106 +104,20 @@ - - com.spotify - docker-maven-plugin - 1.0.0 - - onap/dmaap/zookeeper - src/main/docker - docker-hub - - ${dockertag1} - ${dockertag2} - - true - - - - / - ${project.build.directory} - **/** - - - - - - build-image - install - - build - - - ${skip.docker.build} - - - - - tag-image-project-version - install - - tag - - - onap/dmaap/zookeeper - ${docker.push.registry}/onap/dmaap/zookeeper:${dockertag2} - ${skip.docker.push} - - - - - tag-image-latest - install - - tag - - - onap/dmaap/zookeeper - ${docker.push.registry}/onap/dmaap/zookeeper:${dockertag1} - ${skip.docker.push} - - - - - push-image - deploy - - push - - - ${docker.push.registry}/onap/dmaap/zookeeper:${dockertag2} - ${skip.docker.push} - - - - - push-image-latest - deploy - - push - - - ${docker.push.registry}/onap/dmaap/zookeeper:${dockertag1} - ${skip.docker.push} - - - - - UTF-8 ${maven.build.timestamp} - yyyyMMdd'T'HHmmss'Z' + yyyyMMdd'T'HHmmss'Z' /content/sites/site/org/onap/dmaap/zookeeper/${project.artifactId}/${project.version} true true https://nexus.onap.org nexus3.onap.org:10003 https://nexus.onap.org + 3.4.13 @@ -247,7 +161,7 @@ project.properties['dockertag1']=project.properties['ver'] + "-latest"; project.properties['dockertag2']=project.properties['ver'] + "-" + project.properties['timestamp']; } else { - project.properties['dockertag1']=project.properties['ver']+ "-STAGING-latest"; + project.properties['dockertag1']=project.properties['ver'] + "-STAGING-latest"; project.properties['dockertag2']=project.properties['ver'] + "-STAGING-" + project.properties['timestamp']; } println 'docker tag 1: ' + project.properties['dockertag1']; @@ -257,6 +171,46 @@ + + io.fabric8 + docker-maven-plugin + 0.28.0 + + ${docker.verbose} + ${docker.apiVersion} + ${docker.pull.registry} + ${docker.push.registry} + + + onap/dmaap/zookeeper + + try + Dockerfile + + ${dockertag1} + ${dockertag2} + + + + + + + + generate-images + install + + build + + + + push-images + deploy + + push + + + + 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 -- cgit 1.2.3-korg