DRILL-7496: Update Dockerfile to publish release images under Apache Docker Hub
closes #1947
diff --git a/Dockerfile b/Dockerfile
new file mode 100755
index 0000000..ab32b6c
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,46 @@
+#
+# 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.
+#
+
+# 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.
+
+# Uses intermediate image for building Drill to reduce target image size
+FROM maven:3.6-jdk-8 as build
+
+# Copy project sources into the container
+COPY . /src
+
+WORKDIR /src
+
+# Builds Drill
+RUN mvn clean install -DskipTests -q
+
+# 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) \
+ && mkdir /opt/drill \
+ && mv distribution/target/apache-drill-${VERSION}/apache-drill-${VERSION}/* /opt/drill
+
+# Target image
+FROM openjdk:8u232-jdk
+
+RUN mkdir /opt/drill
+
+COPY --from=build /opt/drill /opt/drill
+
+# Starts Drill in embedded mode and connects to Sqlline
+ENTRYPOINT /opt/drill/bin/drill-embedded
diff --git a/README.md b/README.md
index be306f5..32ab540 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@
Please see the [Apache Drill Website](http://drill.apache.org/) or the [Apache Drill Documentation](http://drill.apache.org/docs/) for more information including:
* Remote Execution Installation Instructions
+ * [Running Drill on Docker instructions](https://drill.apache.org/docs/running-drill-on-docker/)
* Information about how to submit logical and distributed physical plans
* More example queries and sample data
* Find out ways to be involved or discuss Drill
diff --git a/distribution/Dockerfile b/distribution/Dockerfile
old mode 100755
new mode 100644
index 1ea1e456..27372a6
--- a/distribution/Dockerfile
+++ b/distribution/Dockerfile
@@ -16,20 +16,17 @@
# limitations under the License.
#
-FROM centos:7
+# This Dockerfile may be used during development. It adds built binaries from distribution/target folder
+# into the target image based on openjdk:8u232-jdk image.
+
+FROM openjdk:8u232-jdk
# Project version defined in pom.xml is passed as an argument
ARG VERSION
-# JDK 8 is a pre-requisite to run Drill ; 'which' package is needed for drill-config.sh
-RUN yum install -y java-1.8.0-openjdk-devel which ; yum clean all ; rm -rf /var/cache/yum
-
-# The drill tarball is generated upon building the Drill project
-COPY target/apache-drill-$VERSION.tar.gz /tmp
-
-# Drill binaries are extracted into the '/opt/drill' directory
RUN mkdir /opt/drill
-RUN tar -xvzf /tmp/apache-drill-$VERSION.tar.gz --directory=/opt/drill --strip-components 1
+
+COPY target/apache-drill-$VERSION/apache-drill-$VERSION /opt/drill
# Starts Drill in embedded mode and connects to Sqlline
ENTRYPOINT /opt/drill/bin/drill-embedded
diff --git a/distribution/pom.xml b/distribution/pom.xml
index a79e2f4..b6e3484 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -702,7 +702,7 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
- <version>1.4.3</version>
+ <version>1.4.13</version>
<executions>
<execution>
<id>docker-image</id>
diff --git a/docs/dev/Docker.md b/docs/dev/Docker.md
index 9168f1f..8b1495d 100644
--- a/docs/dev/Docker.md
+++ b/docs/dev/Docker.md
@@ -6,71 +6,75 @@
* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
* [Maven 3.3.3 or greater](https://maven.apache.org/download.cgi)
* [Docker CE](https://store.docker.com/search?type=edition&offering=community)
-
+
If you are using an older Mac or PC, additionally configure [docker-machine](https://docs.docker.com/machine/overview/#what-is-docker-machine) on your system
+## Drill Dockerfiles info
+
+ Drill has two Dockerfiles:
+ - Dockerfile placed in the project root is used for Automated Builds in DockerHub. It builds Drill when building Docker images.
+ - Dockerfile placed in the distribution directory may be used during developing the project. It requires a pre-built Drill.
+
## Checkout
```
-git clone https://github.com/apache/drill.git
+$ git clone https://github.com/apache/drill.git
```
+
## Build Drill
```
$ cd drill
$ mvn clean install
```
+
## Build Docker Image
+ To build a Docker image tagged with the current project version using dockerfile maven plugin using pre-built Drill, the following command may be used:
```
-$ cd distribution
-$ mvn dockerfile:build -Pdocker
+$ mvn dockerfile:build -Pdocker -pl distribution
```
## Push Docker Image
-
- By default, the docker image built above is configured to be pushed to [Drill Docker Hub](https://hub.docker.com/r/drill/apache-drill/) to create official Drill Docker images.
-```
-$ cd distribution
-$ mvn dockerfile:push -Pdocker
-```
- You can configure the repository in pom.xml to point to any private or public container registry, or specify it in your mvn command.
-```
-$ cd distribution
-$ mvn dockerfile:push -Pdocker -Pdocker.repository=<my_repo>
+ By default, the docker image built above is configured to be pushed to [Drill Docker Hub](https://hub.docker.com/r/apache/drill/).
+ **Please do not push images manually since it should be done using automated builds in DockerHub.**
+```
+$ mvn dockerfile:push -Pdocker -pl distribution
+```
+ You can configure the repository in `pom.xml` to point to any private or public container registry, or specify it in your mvn command.
+```
+$ mvn dockerfile:push -Pdocker -Ddocker.repository=<my_repo> -pl distribution
```
## Run Docker Container
-
+
Running the Docker container should start Drill in embedded mode and connect to Sqlline.
-```
-$ docker run -i --name drill-1.14.0 -p 8047:8047 -t drill/apache-drill:1.14.0 /bin/bash
-Jun 29, 2018 3:28:21 AM org.glassfish.jersey.server.ApplicationHandler initialize
-INFO: Initiating Jersey application, version Jersey: 2.8 2014-04-29 01:25:26...
-apache drill 1.14.0
-"json ain't no thang"
-0: jdbc:drill:zk=local> select version from sys.version;
-+------------+
-| version |
-+------------+
-| 1.14.0 |
-+------------+
-1 row selected (0.28 seconds)
-```
+```
+$ docker run --rm -i --name drill-1.17.0 -p 8047:8047 -t apache/drill:1.17.0 /bin/bash
+Apache Drill 1.17.0
+"JSON ain't no thang."
+apache drill> select version from sys.version;
++---------+
+| version |
++---------+
+| 1.17.0 |
++---------+
+1 row selected (1.65 seconds)
+```
You can also run the container in detached mode and connect to sqlline using drill-localhost.
-```
-$ docker run -i --name drill-1.14.0 -p 8047:8047 --detach -t drill/apache-drill:1.14.0 /bin/bash
+```
+$ docker run -i --name drill-1.17.0 -p 8047:8047 --detach -t apache/drill:1.17.0 /bin/bash
<displays container ID>
-$ docker exec -it drill-1.14.0 bash
+$ docker exec -it drill-1.17.0 bash
<connects to container>
$ /opt/drill/bin/drill-localhost
-apache drill 1.14.0
-"json ain't no thang"
-0: jdbc:drill:drillbit=localhost> select version from sys.version;
-+------------+
-| version |
-+------------+
-| 1.14.0 |
-+------------+
-1 row selected (0.28 seconds)
+Apache Drill 1.17.0
+"JSON ain't no thang."
+apache drill> select version from sys.version;
++---------+
+| version |
++---------+
+| 1.17.0 |
++---------+
+1 row selected (1.65 seconds)
```
## Querying Data
@@ -87,11 +91,15 @@
```
To query files outside of the container, you can configure [docker volumes](https://docs.docker.com/storage/volumes/#start-a-service-with-volumes)
-
+
## Drill Web UI
Drill web UI can be accessed using http://localhost:8047 once the Drill docker container is up and running. On Windows, you may need to specify the IP address of your system instead of 'localhost'.
+## Automated Builds in DockerHub
+
+ Autobuild triggers a new build to [Drill Docker Hub](https://hub.docker.com/repository/docker/apache/drill) with every git push to Apache master repository or when new tags are added. It uses Dockerfile from project root directory which builds Drill when building docker image.
+
## More information
For more information including how to run Apache Drill in a Docker container, visit the [Apache Drill Documentation](http://drill.apache.org/docs/)
diff --git a/pom.xml b/pom.xml
index 180238d..0ca1200 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
<directMemoryMb>4096</directMemoryMb>
<rat.skip>true</rat.skip>
<license.skip>true</license.skip>
- <docker.repository>drill/apache-drill</docker.repository>
+ <docker.repository>apache/drill</docker.repository>
<antlr.version>4.7.2</antlr.version>
<lowestMavenVersion>3.3.3</lowestMavenVersion>
<commons.net.version>3.6</commons.net.version>