You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by dz...@apache.org on 2021/09/17 08:53:37 UTC

[drill] 03/09: Make the OpenJDK base image name a variable.

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

dzamo pushed a commit to branch 7999-docker-jdk
in repository https://gitbox.apache.org/repos/asf/drill.git

commit aeb41514c1bfc344a8ef774c227bae4e63f422e4
Author: James Turton <ja...@somecomputer.xyz>
AuthorDate: Thu Sep 16 14:28:40 2021 +0200

    Make the OpenJDK base image name a variable.
    
    This allows using a single Dockerfile to target a variety of OpenJDK versions.
---
 .dockerignore |  5 +++--
 Dockerfile    | 44 ++++++++++++++++++++++++++++++--------------
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/.dockerignore b/.dockerignore
index c54d602..aabd129 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -18,9 +18,10 @@
 .dockerignore
 Dockerfile
 .git
+**/.project
 
 # The top-level Dockerfile does its own Maven build so we don't want
-# distribution/target.  See distribution/Dockerfile for a Dockerfile that
+# **/target.  See distribution/Dockerfile for a Dockerfile that
 # builds an image using binaries copied from distribution/target.
 
-distribution/target
+**/target
diff --git a/Dockerfile b/Dockerfile
index 5a2f884..6976a90 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -18,23 +18,33 @@
 
 # This Dockerfile is used for automated builds in DockerHub. It adds
 # project sources into the build image, builds Drill and copies built
-# binaries into the target image based on openjdk:11 image.
+# binaries into the target image based on the image name in BASE_NAME
+# env var which you should set when invoking docker build. 
+# Example BASE_NAME values: openjdk:8-jre, openjdk:11-jre, openjdk:latest
 
 # Uses intermediate image for building Drill to reduce target image size
-FROM maven:3.8.2-jdk-11 as build
-
-# Copy project sources into the container
-COPY . /src
+FROM maven:3.8.2-openjdk-11 as build
 
 WORKDIR /src
 
-# Fetch Drill build deps in a separate layer from the build so that they are
-# cached even if the Maven build fails.  Fetch up to 4 dependencies in 
-# parallel.
-RUN mvn -Dmaven.artifact.threads=4 dependency:resolve
+# Copy project sources into the container
+COPY . .
+
+# Optimisation: build a selection of Drill modules in advance.
+# It isn't necessary to build any modules independently but doing so divides
+# the downloading and compiling up over multiple cacheable layers, better
+# enabling reuse in the event of an isolated change and resume in the event
+# of a build error.  This paragraph can safely be commented out.
+RUN mvn -am -pl tools        -Dmaven.artifact.threads=5 -T1C install -DskipTests
+RUN mvn -am -pl protocol     -Dmaven.artifact.threads=5 -T1C install -DskipTests
+RUN mvn -am -pl common       -Dmaven.artifact.threads=5 -T1C install -DskipTests
+RUN mvn -am -pl logical      -Dmaven.artifact.threads=5 -T1C install -DskipTests
+RUN mvn -am -pl exec         -Dmaven.artifact.threads=5 -T1C install -DskipTests
+RUN mvn -am -pl drill-yarn   -Dmaven.artifact.threads=5 -T1C install -DskipTests
+RUN mvn -am -pl distribution -Dmaven.artifact.threads=5 -T1C install -DskipTests
 
 # Builds Drill
-RUN  mvn -T1C clean install -DskipTests -q
+RUN mvn -Dmaven.artifact.threads=5 -T1C install -DskipTests
 
 # Get project version and copy built binaries into /opt/drill directory
 RUN VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) \
@@ -42,11 +52,17 @@ RUN VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --n
  && mv distribution/target/apache-drill-${VERSION}/apache-drill-${VERSION}/* /opt/drill
 
 # Target image
-FROM openjdk:11
 
-RUN mkdir /opt/drill
+# Set the BASE_IMAGE env var when you invoke docker build.  
+FROM $BASE_IMAGE
+
+ENV DRILL_HOME=/opt/drill
+
+RUN mkdir $DRILL_HOME
 
-COPY --from=build /opt/drill /opt/drill
+COPY --from=build /opt/drill $DRILL_HOME
 
 # Starts Drill in embedded mode and connects to Sqlline
-ENTRYPOINT /opt/drill/bin/drill-embedded
+ENTRYPOINT $DRILL_HOME/bin/drill-embedded
+ 
+