diff options
-rw-r--r-- | pom.xml | 132 | ||||
-rw-r--r-- | src/main/docker/Dockerfile | 122 |
2 files changed, 113 insertions, 141 deletions
@@ -104,106 +104,20 @@ <skip /> </configuration> </plugin> - <plugin> - <groupId>com.spotify</groupId> - <artifactId>docker-maven-plugin</artifactId> - <version>1.0.0</version> - <configuration> - <imageName>onap/dmaap/zookeeper</imageName> - <dockerDirectory>src/main/docker</dockerDirectory> - <serverId>docker-hub</serverId> - <imageTags> - <imageTag>${dockertag1}</imageTag> - <imageTag>${dockertag2}</imageTag> - </imageTags> - <forceTags>true</forceTags> - <resources> - <!-- <resource> <targetPath>/</targetPath> <directory>${dockerLocation}</directory> - <include>${project.build.finalName}.jar</include> </resource> --> - <resource> - <targetPath>/</targetPath> - <directory>${project.build.directory}</directory> - <include>**/**</include> - </resource> - </resources> - </configuration> - <executions> - <execution> - <id>build-image</id> - <phase>install</phase> - <goals> - <goal>build</goal> - </goals> - <configuration> - <skipDockerBuild>${skip.docker.build}</skipDockerBuild> - </configuration> - </execution> - - <execution> - <id>tag-image-project-version</id> - <phase>install</phase> - <goals> - <goal>tag</goal> - </goals> - <configuration> - <image>onap/dmaap/zookeeper</image> - <newName>${docker.push.registry}/onap/dmaap/zookeeper:${dockertag2}</newName> - <skipDockerTag>${skip.docker.push}</skipDockerTag> - </configuration> - </execution> - - <execution> - <id>tag-image-latest</id> - <phase>install</phase> - <goals> - <goal>tag</goal> - </goals> - <configuration> - <image>onap/dmaap/zookeeper</image> - <newName>${docker.push.registry}/onap/dmaap/zookeeper:${dockertag1}</newName> - <skipDockerTag>${skip.docker.push}</skipDockerTag> - </configuration> - </execution> - - <execution> - <id>push-image</id> - <phase>deploy</phase> - <goals> - <goal>push</goal> - </goals> - <configuration> - <imageName>${docker.push.registry}/onap/dmaap/zookeeper:${dockertag2}</imageName> - <skipDockerPush>${skip.docker.push}</skipDockerPush> - </configuration> - </execution> - - <execution> - <id>push-image-latest</id> - <phase>deploy</phase> - <goals> - <goal>push</goal> - </goals> - <configuration> - <imageName>${docker.push.registry}/onap/dmaap/zookeeper:${dockertag1}</imageName> - <skipDockerPush>${skip.docker.push}</skipDockerPush> - </configuration> - </execution> - </executions> - </plugin> - </plugins> </build> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <timestamp>${maven.build.timestamp}</timestamp> - <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> + <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> <sitePath>/content/sites/site/org/onap/dmaap/zookeeper/${project.artifactId}/${project.version}</sitePath> <skip.docker.build>true</skip.docker.build> <skip.docker.push>true</skip.docker.push> <nexusproxy>https://nexus.onap.org</nexusproxy> <docker.push.registry>nexus3.onap.org:10003</docker.push.registry> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> + <zookeeper.dist.version>3.4.13</zookeeper.dist.version> </properties> <!-- Distribution management --> @@ -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 @@ </execution> </executions> </plugin> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>0.28.0</version> + <configuration> + <verbose>${docker.verbose}</verbose> + <apiVersion>${docker.apiVersion}</apiVersion> + <pullRegistry>${docker.pull.registry}</pullRegistry> + <pushRegistry>${docker.push.registry}</pushRegistry> + <images> + <image> + <name>onap/dmaap/zookeeper</name> + <build> + <cleanup>try</cleanup> + <dockerFile>Dockerfile</dockerFile> + <tags> + <tag>${dockertag1}</tag> + <tag>${dockertag2}</tag> + </tags> + </build> + </image> + </images> + </configuration> + <executions> + <execution> + <id>generate-images</id> + <phase>install</phase> + <goals> + <goal>build</goal> + </goals> + </execution> + <execution> + <id>push-images</id> + <phase>deploy</phase> + <goals> + <goal>push</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </profile> 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 |