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

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


The following commit(s) were added to refs/heads/master by this push:
     new eaa4651  docker build cleanup and speed improvements (#8288)
eaa4651 is described below

commit eaa4651fa470a7fc0a678039179eac5d46096ed6
Author: Xavier Léauté <[email protected]>
AuthorDate: Tue Aug 13 08:33:06 2019 -0700

    docker build cleanup and speed improvements (#8288)
    
    * 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         | 49 +++++++++++++++++++++-------------
 distribution/docker/Dockerfile.mysql   | 20 +++++++++-----
 distribution/docker/README.md          | 18 +++++--------
 distribution/docker/docker-compose.yml | 12 ++++-----
 distribution/docker/sha256sums.txt     | 19 -------------
 5 files changed, 55 insertions(+), 63 deletions(-)

diff --git a/distribution/docker/Dockerfile b/distribution/docker/Dockerfile
index 9db493c..1081eb7 100644
--- a/distribution/docker/Dockerfile
+++ b/distribution/docker/Dockerfile
@@ -17,38 +17,49 @@
 # 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
+
 FROM gcr.io/distroless/java:8
 LABEL maintainer="Apache Druid Developers <[email protected]>"
 
 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 --from=builder /opt /opt
 COPY distribution/docker/druid.sh /druid.sh
-RUN chown -R druid:druid /opt/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 \
+ && chmod 775 /opt/druid/var
+
 USER druid
 VOLUME /opt/druid/var
 WORKDIR /opt/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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to