You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by xv...@apache.org on 2019/08/13 05:30:52 UTC

[incubator-druid] branch docker-cleanup created (now 88a5975)

This is an automated email from the ASF dual-hosted git repository.

xvrl pushed a change to branch docker-cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git.


      at 88a5975  docker build cleanup and speed improvements

This branch includes the following new commits:

     new b5f18f3  simplify docker image
     new 88a5975  docker build cleanup and speed improvements

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[incubator-druid] 02/02: docker build cleanup and speed improvements

Posted by xv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xvrl pushed a commit to branch docker-cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git

commit 88a5975eed47605747e92dbd57aa86c51e28e576
Author: Xavier Léauté <xv...@apache.org>
AuthorDate: Mon Aug 12 21:09:42 2019 -0700

    docker build cleanup and speed improvements
    
    * switch builder image to smaller "slim" debian base
    * use built-in pyyaml
    * skip various build checks to speed up compilation
    * create user/group in target image directly
---
 distribution/docker/Dockerfile         | 45 +++++++++++++++++++---------------
 distribution/docker/Dockerfile.mysql   | 20 +++++++++------
 distribution/docker/README.md          | 18 +++++---------
 distribution/docker/docker-compose.yml | 12 ++++-----
 distribution/docker/sha256sums.txt     | 19 --------------
 5 files changed, 50 insertions(+), 64 deletions(-)

diff --git a/distribution/docker/Dockerfile b/distribution/docker/Dockerfile
index 15e8ad7..3ed4c21 100644
--- a/distribution/docker/Dockerfile
+++ b/distribution/docker/Dockerfile
@@ -17,26 +17,31 @@
 # under the License.
 #
 
-FROM maven:3-jdk-8 as builder
+FROM maven:3-jdk-8-slim as builder
 
-RUN apt-get update && apt-get install --no-install-recommends -y python3-pip python3-setuptools python3-wheel\
-  && rm -rf /var/lib/apt/lists/*
-RUN pip3 install --no-cache-dir pyyaml
+RUN export DEBIAN_FRONTEND=noninteractive \
+    && apt-get -qq update \
+    && apt-get -qq -y install --no-install-recommends python3 python3-yaml
 
 COPY . /src
 WORKDIR /src
-RUN mvn dependency:go-offline install -ff -q -B -DskipTests -Dforbiddenapis.skip=true -Pdist -Pbundle-contrib-exts
+RUN mvn -B -ff -q dependency:go-offline \
+      install \
+      -Pdist,bundle-contrib-exts \
+      -DskipTests \
+      -Danimal.sniffer.skip=true \
+      -Dcheckstyle.skip=true \
+      -Denforcer.skip=true \
+      -Dforbiddenapis.skip=true \
+      -Dmaven.javadoc.skip=true \
+      -Dpmd.skip=true \
+      -Dspotbugs.skip=true
 
-RUN \
- VER=$(mvn -B org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.version -q -DforceStdout=true -f pom.xml 2>/dev/null) \
- && tar -zxf ./distribution/target/apache-druid-${VER}-bin.tar.gz -C /opt \
- && ln -s /opt/apache-druid-${VER} /opt/druid
-
-RUN addgroup --gid 1000 druid \
- && adduser --home /opt/druid --shell /bin/sh --no-create-home --uid 1000 --gecos '' --gid 1000 --disabled-password druid \
- && mkdir -p /opt/druid/var \
- && chown -R druid:druid /opt/druid \
- && chmod 775 /opt/druid/var
+RUN VERSION=$(mvn -B -q org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate \
+      -Dexpression=project.version -DforceStdout=true
+    ) \
+ && tar -zxf ./distribution/target/apache-druid-${VERSION}-bin.tar.gz -C /opt \
+ && ln -s /opt/apache-druid-${VERSION} /opt/druid
 
 FROM amd64/busybox:1.30.0-glibc as busybox
 
@@ -46,13 +51,13 @@ LABEL maintainer="Apache Druid Developers <de...@druid.apache.org>"
 COPY --from=busybox /bin/busybox /busybox/busybox
 RUN ["/busybox/busybox", "--install", "/bin"]
 
-COPY --from=extractor /opt /opt
-COPY ./docker/druid.sh /druid.sh
+COPY --from=builder /opt /opt
+COPY distribution/docker/druid.sh /druid.sh
 
-RUN addgroup --gid 1000 druid \
- && adduser -h /opt/druid -s /bin/sh -H -u 1000 -g '' -G druid -D druid \
+RUN addgroup -S -g 1000 druid \
+ && adduser -S -u 1000 -D -H -h /opt/druid -s /bin/sh -g '' -G druid druid \
  && mkdir -p /opt/druid/var \
- && chown -R druid:druid /opt/ \
+ && chown -R druid:druid /opt \
  && chmod 775 /opt/druid/var
 
 USER druid
diff --git a/distribution/docker/Dockerfile.mysql b/distribution/docker/Dockerfile.mysql
index 5664dc8..bba0721 100644
--- a/distribution/docker/Dockerfile.mysql
+++ b/distribution/docker/Dockerfile.mysql
@@ -17,12 +17,18 @@
 # under the License.
 #
 
-ARG DRUID_RELEASE=druid/druid:0.14.0
+ARG DRUID_RELEASE
 FROM $DRUID_RELEASE
 
-COPY sha256sums.txt /tmp
-RUN wget -O /opt/druid/extensions/mysql-metadata-storage/mysql-connector-java-5.1.38.jar https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar \
- && sed -e '/^#/d' /tmp/sha256sums.txt > /tmp/sha256sums-stripped.txt \
- && sha256sum -c /tmp/sha256sums-stripped.txt \
- && rm -f /opt/druid/lib/mysql-connector-java-5.1.38.jar \
- && ln -s /opt/druid/extensions/mysql-metadata-storage/mysql-connector-java-5.1.38.jar /opt/druid/lib
+WORKDIR /opt/druid/extensions/mysql-metadata-storage
+
+ARG MYSQL_URL=https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar
+ARG MYSQL_JAR=mysql-connector-java-5.1.38.jar
+# https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar.sha1
+ARG MYSQL_SHA=dbbd7cd309ce167ec8367de4e41c63c2c8593cc5
+
+RUN wget -q ${MYSQL_URL} \
+ && echo "${MYSQL_SHA}  ${MYSQL_JAR}" | sha1sum -c \
+ && ln -s ../extensions/mysql-metadata-storage/${MYSQL_JAR} /opt/druid/lib
+
+WORKDIR /opt/druid
diff --git a/distribution/docker/README.md b/distribution/docker/README.md
index 64f51d6..09a1e7c 100644
--- a/distribution/docker/README.md
+++ b/distribution/docker/README.md
@@ -19,7 +19,7 @@
 
 ## Build
 
-From the root of the repo, run `docker build -t druid:tag -f distribution/docker/Dockerfile .`
+From the root of the repo, run `docker build -t apache/incubator-druid:tag -f distribution/docker/Dockerfile .`
 
 ## Run
 
@@ -27,16 +27,10 @@ Edit `environment` to suite. Run `docker-compose -f distribution/docker/docker-c
 
 ## MySQL Database Connector
 
-This image contains solely the postgres metadata database connector. If you need
-the mysql metadata storage connector, consider adding these lines before the `addgroup`
-run-command.
+This image contains solely the postgres metadata storage connector. If you
+need the mysql metadata storage connector, you can use Dockerfile.mysql to add
+it to the base image above.
 
-```
-RUN wget -O /opt/druid/extensions/mysql-metadata-storage/mysql-connector-java-5.1.38.jar http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar \
- && sha256sum --ignore-missing -c /src/distribution/docker/sha256sums.txt \
- && ln -s /opt/druid/extensions/mysql-metadata-storage/mysql-connector-java-5.1.38.jar /opt/druid/lib
-```
+`docker build -t apache/incubator-druid:tag-mysql --build-arg DRUID_RELEASE=apache/incubator-druid:tag -f distribution/docker/Dockerfile.mysql .`
 
-Alternatively, `cd src/distribution/docker; docker build -t druid:mysql --build-arg DRUID_RELEASE=upstream -f Dockerfile.mysql .`
-
-where `upstream` is the version to use as the base (e.g. druid:0.14.0 from Dockerhub)
+where `druid:tag` is the version to use as the base.
diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml
index 891d383..7160dcd 100644
--- a/distribution/docker/docker-compose.yml
+++ b/distribution/docker/docker-compose.yml
@@ -46,7 +46,7 @@ services:
       - ZOO_MY_ID=1
 
   coordinator:
-    image: druid
+    image: apache/incubator-druid
     container_name: coordinator
     volumes:
       - coordinator_var:/opt/druid/var
@@ -61,7 +61,7 @@ services:
       - environment
 
   broker:
-    image: druid
+    image: apache/incubator-druid
     container_name: broker
     volumes:
       - broker_var:/opt/druid/var
@@ -77,7 +77,7 @@ services:
       - environment
 
   historical:
-    image: druid
+    image: apache/incubator-druid
     container_name: historical
     volumes:
       - historical_var:/opt/druid/var
@@ -93,7 +93,7 @@ services:
       - environment
 
   overlord:
-    image: druid
+    image: apache/incubator-druid
     container_name: overlord
     volumes:
       - overlord_var:/opt/druid/var
@@ -108,7 +108,7 @@ services:
       - environment
 
   middlemanager:
-    image: druid
+    image: apache/incubator-druid
     container_name: middlemanager
     volumes:
       - middle_var:/opt/druid/var
@@ -124,7 +124,7 @@ services:
       - environment
 
   router:
-    image: druid
+    image: apache/incubator-druid
     container_name: router
     volumes:
       - router_var:/opt/druid/var
diff --git a/distribution/docker/sha256sums.txt b/distribution/docker/sha256sums.txt
deleted file mode 100644
index 6f858cd..0000000
--- a/distribution/docker/sha256sums.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-b95bf9fe25cb5428f378a62fc842e177ca004b4ae1f9054968b2a396dcc1ec22  /opt/druid/extensions/mysql-metadata-storage/mysql-connector-java-5.1.38.jar


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[incubator-druid] 01/02: simplify docker image

Posted by xv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xvrl pushed a commit to branch docker-cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git

commit b5f18f362a9717f3fe2851ea8cbc92cd23994245
Author: Xavier Léauté <xv...@apache.org>
AuthorDate: Sat Aug 10 22:51:32 2019 -0700

    simplify docker image
---
 distribution/docker/Dockerfile | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/distribution/docker/Dockerfile b/distribution/docker/Dockerfile
index 9db493c..15e8ad7 100644
--- a/distribution/docker/Dockerfile
+++ b/distribution/docker/Dockerfile
@@ -39,16 +39,22 @@ RUN addgroup --gid 1000 druid \
  && chmod 775 /opt/druid/var
 
 FROM amd64/busybox:1.30.0-glibc as busybox
+
 FROM gcr.io/distroless/java:8
 LABEL maintainer="Apache Druid Developers <de...@druid.apache.org>"
 
 COPY --from=busybox /bin/busybox /busybox/busybox
 RUN ["/busybox/busybox", "--install", "/bin"]
-COPY --from=builder /etc/passwd /etc/passwd
-COPY --from=builder /etc/group /etc/group
-COPY --from=builder --chown=druid /opt /opt
-COPY distribution/docker/druid.sh /druid.sh
-RUN chown -R druid:druid /opt/druid
+
+COPY --from=extractor /opt /opt
+COPY ./docker/druid.sh /druid.sh
+
+RUN addgroup --gid 1000 druid \
+ && adduser -h /opt/druid -s /bin/sh -H -u 1000 -g '' -G druid -D druid \
+ && mkdir -p /opt/druid/var \
+ && chown -R druid:druid /opt/ \
+ && chmod 775 /opt/druid/var
+
 USER druid
 VOLUME /opt/druid/var
 WORKDIR /opt/druid


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org