From 4f6b67644336efd2b015fea9b97ab4e09927f486 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Wed, 16 Oct 2019 13:27:27 +0900 Subject: [PATCH 1/3] Build master images of slim. --- docker/Dockerfile | 74 ++++++++++++++++++++++++++++++++++++++++-- docker/README.md | 6 ++++ docker/hooks/build | 4 ++- docker/hooks/post_push | 1 + 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8cbcf5effea..bc83054cb80 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,6 +12,10 @@ # the License. # +##### +# zipkin-builder - An image that caches build repositories (.m2, .npm) to speed up subsequent builds. +##### + FROM openzipkin/zipkin-builder as built WORKDIR /code @@ -20,13 +24,18 @@ COPY . /code/ RUN mvn -B --no-transfer-progress package -DskipTests=true -pl zipkin-server -am -RUN mkdir -p /zipkin && cp zipkin-server/target/zipkin-server-*-exec.jar /zipkin && cd /zipkin && jar xf *.jar && rm *.jar +RUN mkdir -p /zipkin && cp zipkin-server/target/zipkin-server-*-exec.jar /zipkin && cd /zipkin && jar xf *.jar +RUN mkdir -p /zipkin-slim && cp zipkin-server/target/zipkin-server-*-slim.jar /zipkin-slim && cd /zipkin-slim && jar xf *.jar FROM maven:3-jdk-11-slim as zipkin-builder COPY --from=built /root/.m2 /root/.m2 COPY --from=built /root/.npm /root/.npm +##### +# zipkin-ui - An image containing the Zipkin web frontend only, served by NGINX +##### + FROM nginx:1.16-alpine as zipkin-ui LABEL MAINTAINER Zipkin "https://zipkin.io/" @@ -43,6 +52,65 @@ EXPOSE 80 CMD ["/usr/local/bin/nginx.sh"] +##### +# zipkin-server-slim - An image containing the slim distribution of Zipkin server. +##### + +FROM openzipkin/jre-full:11.0.4-11.33 as zipkin-server-slim +LABEL MAINTAINER Zipkin "https://zipkin.io/" + +# Use to set heap, trust store or other system properties. +ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom +# 3rd party modules like zipkin-aws will apply profile settings with this +ENV MODULE_OPTS= + +RUN adduser -g '' -h /zipkin -D zipkin + +# Add environment settings for supported storage types +COPY --from=built --chown=zipkin /zipkin-slim/ /zipkin/ +COPY --chown=zipkin docker/zipkin/ /zipkin/ +WORKDIR /zipkin + +RUN ln -s /busybox/* /bin + +USER zipkin + +EXPOSE 9410 9411 + +# This health check was added for Docker Hub automated test service. Parameters +# were changed in order to mark success faster. You may want to change these +# further in production. +# +# +# By default, the Docker health check runs after 30s, and if a failure occurs, +# it waits 30s to try again. This implies a minimum of 30s before the server is +# marked healthy. +# +# https://docs.docker.com/engine/reference/builder/#healthcheck +# +# We expect the server startup to take less than 10 seconds, even in a fresh +# start. Some health checks will trigger a slow "first request" due to schema +# setup (ex this is the case in Elasticsearch and Cassandra). However, we don't +# want to force an initial delay of 30s as defaults would. +# +# Instead, we lower the interval and timeout from 30s to 5s. If a server starts +# in 7s and takes another 2s to install schema, it can still pass in 10s vs 30s. +# +# We retain the 30s even if it would be an excessively long startup. This is to +# accomodate test containers, which can boot slower than production sites, and +# any knock-on effects of that, like slow dependent storage containers which are +# simultaneously bootstrapping. If in production, you have a 30s startup, please +# report to https://gitter.im/openzipkin/zipkin including the values of the +# /health and /info endpoints as this would be unexpected. +# +HEALTHCHECK --interval=5s --start-period=30s --timeout=5s CMD wget --quiet http://localhost:9411/health || exit 1 + +ENTRYPOINT ["/busybox/sh", "run.sh"] + +##### +# zipkin-server - An image containing the full distribution of Zipkin server. +##### + FROM openzipkin/jre-full:11.0.4-11.33 as zipkin-server LABEL MAINTAINER Zipkin "https://zipkin.io/" @@ -51,14 +119,14 @@ ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom # 3rd party modules like zipkin-aws will apply profile settings with this ENV MODULE_OPTS= -RUN ["/busybox/sh", "-c", "adduser -g '' -h /zipkin -D zipkin"] +RUN adduser -g '' -h /zipkin -D zipkin # Add environment settings for supported storage types COPY --from=built --chown=zipkin /zipkin/ /zipkin/ COPY --chown=zipkin docker/zipkin/ /zipkin/ WORKDIR /zipkin -RUN ["/busybox/sh", "-c", "ln -s /busybox/* /bin"] +RUN ln -s /busybox/* /bin USER zipkin diff --git a/docker/README.md b/docker/README.md index a9e33695f9f..0a5aca27971 100644 --- a/docker/README.md +++ b/docker/README.md @@ -7,6 +7,12 @@ like $ docker build -t openzipkin/zipkin:test -f docker/Dockerfile . ``` +If you want the slim distribution instead, run something like + +```bash +$ docker build -t openzipkin/zipkin:test -f docker/Dockerfile . --target zipkin-server-slim +``` + ## zipkin-ui Docker image We also provide an image that only contains the static parts of the Zipkin UI served directly with diff --git a/docker/hooks/build b/docker/hooks/build index f6d184221ef..21eaee45130 100644 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -9,9 +9,11 @@ set -v # to top level. cd .. -docker build -f $DOCKERFILE_PATH -t $IMAGE_NAME . +docker build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . +docker build -f "$DOCKERFILE_PATH" -t "${IMAGE_NAME}-slim" . --target zipkin-server-slim IFS=',' read -ra TAGS <<< "$DOCKER_TAG" for tag in ${TAGS[@]}; do docker tag "$IMAGE_NAME" "${DOCKER_REPO}:${tag}" + docker tag "${IMAGE_NAME}-slim" "${DOCKER_REPO}:${tag}-slim" done diff --git a/docker/hooks/post_push b/docker/hooks/post_push index f793b43cceb..23a9a74e222 100644 --- a/docker/hooks/post_push +++ b/docker/hooks/post_push @@ -8,6 +8,7 @@ if [[ "$DOCKER_REPO" == "index.docker.io/openzipkin/zipkin" ]]; then IFS=',' read -ra TAGS <<< "$DOCKER_TAG" for tag in ${TAGS[@]}; do docker push "openzipkin/zipkin-ui:$tag" + docker push "${DOCKER_REPO}:${tag}-slim" done if [[ "$DOCKER_TAG" == "master" ]]; then From 3dbbfec7790c508760f8cf7257b27f52d99a36f1 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Wed, 16 Oct 2019 14:07:30 +0900 Subject: [PATCH 2/3] Restore removal --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index bc83054cb80..e724cc8ac20 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -24,8 +24,8 @@ COPY . /code/ RUN mvn -B --no-transfer-progress package -DskipTests=true -pl zipkin-server -am -RUN mkdir -p /zipkin && cp zipkin-server/target/zipkin-server-*-exec.jar /zipkin && cd /zipkin && jar xf *.jar -RUN mkdir -p /zipkin-slim && cp zipkin-server/target/zipkin-server-*-slim.jar /zipkin-slim && cd /zipkin-slim && jar xf *.jar +RUN mkdir -p /zipkin && cp zipkin-server/target/zipkin-server-*-exec.jar /zipkin && cd /zipkin && jar xf *.jar && rm *.jar +RUN mkdir -p /zipkin-slim && cp zipkin-server/target/zipkin-server-*-slim.jar /zipkin-slim && cd /zipkin-slim && jar xf *.jar && rm *.jar FROM maven:3-jdk-11-slim as zipkin-builder From eabf1e4fcbcc3ca31c20877bfc4d0582d3560eb7 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Wed, 16 Oct 2019 14:13:00 +0900 Subject: [PATCH 3/3] Slim slim --- docker/Dockerfile | 4 ++-- docker/README.md | 2 +- docker/hooks/build | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e724cc8ac20..84925264f7b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -53,10 +53,10 @@ EXPOSE 80 CMD ["/usr/local/bin/nginx.sh"] ##### -# zipkin-server-slim - An image containing the slim distribution of Zipkin server. +# zipkin-slim - An image containing the slim distribution of Zipkin server. ##### -FROM openzipkin/jre-full:11.0.4-11.33 as zipkin-server-slim +FROM openzipkin/jre-full:11.0.4-11.33 as zipkin-slim LABEL MAINTAINER Zipkin "https://zipkin.io/" # Use to set heap, trust store or other system properties. diff --git a/docker/README.md b/docker/README.md index 0a5aca27971..8115bccadbd 100644 --- a/docker/README.md +++ b/docker/README.md @@ -10,7 +10,7 @@ $ docker build -t openzipkin/zipkin:test -f docker/Dockerfile . If you want the slim distribution instead, run something like ```bash -$ docker build -t openzipkin/zipkin:test -f docker/Dockerfile . --target zipkin-server-slim +$ docker build -t openzipkin/zipkin:test -f docker/Dockerfile . --target zipkin-slim ``` ## zipkin-ui Docker image diff --git a/docker/hooks/build b/docker/hooks/build index 21eaee45130..b0a06b9b2d2 100644 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -10,7 +10,7 @@ set -v cd .. docker build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . -docker build -f "$DOCKERFILE_PATH" -t "${IMAGE_NAME}-slim" . --target zipkin-server-slim +docker build -f "$DOCKERFILE_PATH" -t "${IMAGE_NAME}-slim" . --target zipkin-slim IFS=',' read -ra TAGS <<< "$DOCKER_TAG" for tag in ${TAGS[@]}; do