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 07837279bf9b04368ebc4fdf572d78a8058bbb0c Author: James Turton <[email protected]> AuthorDate: Thu Sep 2 12:05:42 2021 +0200 DRILL-7999 Base Docker image on maven:3.8.2-jdk-11 and openjdk-11 Add Apache license to .dockerignore. Make the OpenJDK base image name a variable. This allows using a single Dockerfile to target a variety of OpenJDK versions. Base the build container on OpenJDK 8 to maintain compat with JDK >= 8 Remove individual module build commands. I had hoped these module build layers would be an optimisation but I now think they result in Maven doing rework rather than building incrementally. Add hooks/ dir containing hooks for Docker Hub image builder. See the committed README for more information. Add openjdk-8 tag to drill:latest, separate version numbers with hyphen, newest = 14. Add Apache License to Docker Hub hooks in hooks/ Make the build container base image name an ARG, BUILD_BASE_IMAGE. Add #!/bin/bash shebang to build hooks. Base image tags on Docker Hub env var $DOCKER_TAG. --- .dockerignore | 30 ++++++++++++++++++++++++++++++ Dockerfile | 43 ++++++++++++++++++++++++++++++++----------- hooks/README | 9 +++++++++ hooks/build | 39 +++++++++++++++++++++++++++++++++++++++ hooks/push | 23 +++++++++++++++++++++++ 5 files changed, 133 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a2292be --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +# +# 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. + +.dockerignore +Dockerfile + +# Excluding the .git directory would be a meaningful saving but the build +# makes use of the git-commit-id plugin and that wants the git repo to be +# present. +# .git + +# The top-level Dockerfile does its own Maven build so we don't want +# **/target. See distribution/Dockerfile for a Dockerfile that +# builds an image using binaries copied from distribution/target. + +**/target diff --git a/Dockerfile b/Dockerfile index cfe3a2d..ee70ed4 100755 --- a/Dockerfile +++ b/Dockerfile @@ -16,19 +16,35 @@ # limitations under the License. # -# 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:8u232-jdk image. +# 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. -# Uses intermediate image for building Drill to reduce target image size -FROM maven:3.6.3-jdk-8 as build +# Example usage: +# +# {docker|podman} build \ +# --build-arg BUILD_BASE_IMAGE=maven:3.8.2-openjdk-11 \ +# --build-arg BASE_IMAGE=openjdk:11-jre \ +# -t apache/drill-openjdk-11 -# Copy project sources into the container -COPY . /src +# Unless otherwise specified, the intermediate container image will be +# based on the following default. +ARG BUILD_BASE_IMAGE=maven:3.8.2-openjdk-8 + +# Unless otherwise specified, the final container image will be based on +# the following default. +ARG BASE_IMAGE=openjdk:8-jre + +# Uses intermediate image for building Drill to reduce target image size +FROM $BUILD_BASE_IMAGE as build WORKDIR /src +# Copy project sources into the container +COPY . . + # Builds Drill -RUN mvn clean install -DskipTests -q +RUN mvn -Dmaven.artifact.threads=5 -T1C clean 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) \ @@ -36,11 +52,16 @@ 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:8u232-jdk -RUN mkdir /opt/drill +# Set the BASE_IMAGE build arg when you invoke docker build. +FROM $BASE_IMAGE + +ENV DRILL_HOME=/opt/drill -COPY --from=build /opt/drill /opt/drill +RUN mkdir $DRILL_HOME + +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 + diff --git a/hooks/README b/hooks/README new file mode 100644 index 0000000..53f7b03 --- /dev/null +++ b/hooks/README @@ -0,0 +1,9 @@ +This directory exists for Docker Hub's automatic image building. The hooks +here override the default build, test and push commands used by Docker Hub +to build the published Docker images of Drill. The reason they are overridden +is so that we can produce Docker images based on multiple OpenJDK base images, +all using a single Dockerfile. Also see + +../Dockerfile +https://docs.docker.com/docker-hub/builds/advanced/ + diff --git a/hooks/build b/hooks/build new file mode 100755 index 0000000..2e4c99c --- /dev/null +++ b/hooks/build @@ -0,0 +1,39 @@ +#!/bin/bash +# +# 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. + +docker build \ + --build-arg BUILD_BASE_IMAGE=maven:3.8.2-openjdk-8 \ + --build-arg BASE_IMAGE=openjdk:8-jre \ + -t apache/drill:$DOCKER_TAG-openjdk-8 \ + -t apache/drill:$DOCKER_TAG \ + . + +docker build \ + --build-arg BUILD_BASE_IMAGE=maven:3.8.2-openjdk-11 \ + --build-arg BASE_IMAGE=openjdk:11-jre \ + -t apache/drill:$DOCKER_TAG-openjdk-11 \ + . + +# Maven images in Docker Hub jump from OpenJDK 11 to OpenJDK 16 so we build +# with OpenJDK 11 for the OpenJDK 14-based container. + +docker build \ + --build-arg BUILD_BASE_IMAGE=maven:3.8.2-openjdk-11 \ + --build-arg BASE_IMAGE=openjdk:14 \ + -t apache/drill:$DOCKER_TAG-openjdk-14 \ + . diff --git a/hooks/push b/hooks/push new file mode 100755 index 0000000..69aa52c --- /dev/null +++ b/hooks/push @@ -0,0 +1,23 @@ +#!/bin/bash +# +# 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. + +docker push apache/drill:$DOCKER_TAG +docker push apache/drill:$DOCKER_TAG-openjdk-8 +docker push apache/drill:$DOCKER_TAG-openjdk-11 +docker push apache/drill:$DOCKER_TAG-openjdk-14 +
