You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by el...@apache.org on 2017/04/06 17:42:11 UTC
calcite-avatica git commit: [CALCITE-1364] Docker images for an
avatica server
Repository: calcite-avatica
Updated Branches:
refs/heads/master c42a01716 -> c43aec544
[CALCITE-1364] Docker images for an avatica server
* Includes a base Docker image for an Avatica server with alpine
* Includes "implementations" for hsqldb, postgresql, mysql
* Includes docker-compose files for postgresl/mysql + avatica
* Includes a base Docker image suitable for auto-promotion to Dockerhub
* Includes verification of versions in the Dockerhub Dockerfile
* An assembly built containing all docker files
* Site update to describe what is present
Closes apache/calcite-avatica#3
Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica/commit/c43aec54
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica/tree/c43aec54
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica/diff/c43aec54
Branch: refs/heads/master
Commit: c43aec5449653d08dc4c183742aa28528ee280a9
Parents: c42a017
Author: Josh Elser <el...@apache.org>
Authored: Sun Mar 26 14:50:29 2017 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Apr 6 13:33:03 2017 -0400
----------------------------------------------------------------------
docker/README.md | 46 ++++++
docker/pom.xml | 124 +++++++++++++++
docker/src/assembly/docker-files.xml | 35 +++++
docker/src/main/docker/Dockerfile | 36 +++++
docker/src/main/docker/hypersql/Dockerfile | 26 ++++
docker/src/main/docker/hypersql/build.sh | 20 +++
docker/src/main/docker/mysql/Dockerfile | 25 +++
docker/src/main/docker/mysql/build.sh | 20 +++
docker/src/main/docker/mysql/docker-compose.yml | 34 +++++
docker/src/main/docker/postgresql/Dockerfile | 25 +++
docker/src/main/docker/postgresql/build.sh | 20 +++
.../main/docker/postgresql/docker-compose.yml | 34 +++++
docker/src/main/dockerhub/Dockerfile | 38 +++++
.../verify-dockerhub-dockerfile-version.groovy | 53 +++++++
pom.xml | 16 ++
site/_data/docs.yml | 1 +
site/_docs/docker_images.md | 151 +++++++++++++++++++
standalone-server/pom.xml | 4 +-
.../avatica/standalone/StandaloneServer.java | 14 +-
19 files changed, 718 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/README.md
----------------------------------------------------------------------
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..2633a9c
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,46 @@
+<!--
+{% comment %}
+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.
+{% endcomment %}
+-->
+
+This module contains a number of Dockerfiles to ease testing of
+Avatica clients against a known-server.
+
+## Docker
+
+`src/main/docker` contains a number of Dockerfiles and Docker-compose
+configuration files to launch a standalone-Avatica server. Maven automation
+exists for the base Docker image "avatica-server" which can be invoked with
+the "-Pdocker" Maven profile.
+
+The other Dockerfiles must be built by hand.
+
+### Provided Images
+
+A number of Dockerfiles for different databases are provided. Presently, they include:
+
+* [HyperSQL](https://github.com/apache/calcite-avatica/tree/master/docker/src/main/docker/hypersql)
+* [MySQL](https://github.com/apache/calcite-avatica/tree/master/docker/src/main/docker/mysql)
+* [PostgreSQL](https://github.com/apache/calcite-avatica/tree/master/docker/src/main/docker/postgresql)
+
+## Dockerhub
+
+`src/main/dockerhub` contains a copy of the same `avatica-server` Dockerfile
+that is present in `src/main/docker` that is designed to be used with the
+automation around publishing Docker images to the Apache Dockerhub account.
+
+It is not expected that users would interact with this Dockerfile.
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/pom.xml
----------------------------------------------------------------------
diff --git a/docker/pom.xml b/docker/pom.xml
new file mode 100644
index 0000000..f555ab9
--- /dev/null
+++ b/docker/pom.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.calcite.avatica</groupId>
+ <artifactId>avatica-parent</artifactId>
+ <version>1.10.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>avatica-docker</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Calcite Avatica Docker images</name>
+ <description>Docker images for the Avatica server</description>
+
+ <properties>
+ <top.dir>${project.basedir}/..</top.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.calcite.avatica</groupId>
+ <artifactId>avatica-standalone-server</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <!-- Use the execution instead of configuration to bind it to package -->
+ <executions>
+ <execution>
+ <id>binary-assembly</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/docker-files.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <!-- Profile for building official Docker images. Not bound to build phases since that would require anyone build to have the Docker engine installed on their machine -->
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <imageName>avatica-server</imageName>
+ <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
+ <imageTags>
+ <imageTag>${project.version}</imageTag>
+ <imageTag>latest</imageTag>
+ </imageTags>
+ <resources>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${top.dir}/standalone-server/target</directory>
+ <include>avatica-standalone-server-${project.version}-shaded.jar</include>
+ </resource>
+ </resources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <!-- Need to verify that the URL we're pulling from in the Dockerfile is correct for this release -->
+ <id>apache-release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check-dockerhub-dockerfile-version</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>${project.basedir}/src/test/scripts/verify-dockerhub-dockerfile-version.groovy</source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/assembly/docker-files.xml
----------------------------------------------------------------------
diff --git a/docker/src/assembly/docker-files.xml b/docker/src/assembly/docker-files.xml
new file mode 100644
index 0000000..5bfcce5
--- /dev/null
+++ b/docker/src/assembly/docker-files.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>docker-files</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/docker</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/Dockerfile b/docker/src/main/docker/Dockerfile
new file mode 100644
index 0000000..e5b48de
--- /dev/null
+++ b/docker/src/main/docker/Dockerfile
@@ -0,0 +1,36 @@
+# 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.
+
+FROM openjdk:8-jre-alpine
+MAINTAINER Apache Avatica <de...@calcite.apache.org>
+
+# Create an avatica user
+RUN addgroup -S avatica && adduser -S -G avatica avatica
+RUN mkdir -p /home/avatica/classpath
+
+# Dependencies
+ADD avatica-standalone-server-*-shaded.jar /home/avatica/classpath
+
+# Make sure avatica owns its files
+RUN chown -R avatica: /home/avatica
+
+# Expose the default port as a convenience
+EXPOSE 8765
+
+# Switch off of the root user
+# TODO Would like to do this, but screws up downstream due to https://github.com/docker/docker/issues/6119
+# USER avatica
+
+ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer", "-p", "8765"]
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/hypersql/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/hypersql/Dockerfile b/docker/src/main/docker/hypersql/Dockerfile
new file mode 100644
index 0000000..a79dfa2
--- /dev/null
+++ b/docker/src/main/docker/hypersql/Dockerfile
@@ -0,0 +1,26 @@
+# 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.
+
+FROM avatica-server:latest
+MAINTAINER Apache Avatica <de...@calcite.apache.org>
+
+ARG HSQLDB_VERSION="2.3.1"
+
+# Dependencies
+ADD https://repo1.maven.org/maven2/net/hydromatic/scott-data-hsqldb/0.1/scott-data-hsqldb-0.1.jar /home/avatica/classpath/
+ADD https://repo1.maven.org/maven2/org/hsqldb/hsqldb/${HSQLDB_VERSION}/hsqldb-${HSQLDB_VERSION}.jar /home/avatica/classpath/
+
+# Add on to avatica-server's entrypoint
+CMD ["-u", "jdbc:hsqldb:res:scott"]
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/hypersql/build.sh
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/hypersql/build.sh b/docker/src/main/docker/hypersql/build.sh
new file mode 100755
index 0000000..1360807
--- /dev/null
+++ b/docker/src/main/docker/hypersql/build.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+cd "$(dirname "$0")"
+
+docker build . -t avatica-hsqldb-server
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/mysql/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/mysql/Dockerfile b/docker/src/main/docker/mysql/Dockerfile
new file mode 100644
index 0000000..c8a5d5b
--- /dev/null
+++ b/docker/src/main/docker/mysql/Dockerfile
@@ -0,0 +1,25 @@
+# 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.
+
+FROM avatica-server:latest
+MAINTAINER Apache Avatica <de...@calcite.apache.org>
+
+ARG MYSQL_VERSION="5.1.41"
+
+# Dependencies
+ADD https://repo1.maven.org/maven2/mysql/mysql-connector-java/${MYSQL_VERSION}/mysql-connector-java-${MYSQL_VERSION}.jar /home/avatica/classpath/
+RUN chown -R avatica: /home/avatica
+
+USER avatica
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/mysql/build.sh
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/mysql/build.sh b/docker/src/main/docker/mysql/build.sh
new file mode 100755
index 0000000..9aca34d
--- /dev/null
+++ b/docker/src/main/docker/mysql/build.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+cd "$(dirname "$0")"
+
+docker build . -t avatica-mysql-server
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/mysql/docker-compose.yml
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/mysql/docker-compose.yml b/docker/src/main/docker/mysql/docker-compose.yml
new file mode 100644
index 0000000..c20eaf5
--- /dev/null
+++ b/docker/src/main/docker/mysql/docker-compose.yml
@@ -0,0 +1,34 @@
+# 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.
+
+version: '2'
+services:
+ avatica:
+ ports:
+ - "8765:8765"
+ links:
+ - mysql
+ build: ./
+ image: avatica-mysql-server
+ command: "-u 'jdbc:mysql://mysql:3306/avatica'"
+ depends_on:
+ - mysql
+ mysql:
+ image: mysql:5.7
+ environment:
+ MYSQL_ROOT_PASSWORD: avatica
+ MYSQL_DATABASE: avatica
+ MYSQL_USER: user
+ MYSQL_PASSWORD: password
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/postgresql/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/postgresql/Dockerfile b/docker/src/main/docker/postgresql/Dockerfile
new file mode 100644
index 0000000..501f15d
--- /dev/null
+++ b/docker/src/main/docker/postgresql/Dockerfile
@@ -0,0 +1,25 @@
+# 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.
+
+FROM avatica-server:latest
+MAINTAINER Apache Avatica <de...@calcite.apache.org>
+
+ARG POSTGRESQL_VERSION="42.0.0"
+
+# Dependencies
+ADD https://repo1.maven.org/maven2/org/postgresql/postgresql/${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.jar /home/avatica/classpath/
+RUN chown -R avatica: /home/avatica
+
+USER avatica
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/postgresql/build.sh
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/postgresql/build.sh b/docker/src/main/docker/postgresql/build.sh
new file mode 100755
index 0000000..e98efed
--- /dev/null
+++ b/docker/src/main/docker/postgresql/build.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+cd "$(dirname "$0")"
+
+docker build . -t avatica-postgresql-server
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/docker/postgresql/docker-compose.yml
----------------------------------------------------------------------
diff --git a/docker/src/main/docker/postgresql/docker-compose.yml b/docker/src/main/docker/postgresql/docker-compose.yml
new file mode 100644
index 0000000..a4f1c8b
--- /dev/null
+++ b/docker/src/main/docker/postgresql/docker-compose.yml
@@ -0,0 +1,34 @@
+# 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.
+
+version: '2'
+services:
+ avatica:
+ ports:
+ - "8765:8765"
+ links:
+ - postgresql
+ build: ./
+ image: avatica-postgresql-server
+ # Default port for the docker image
+ command: "-u 'jdbc:postgresql://postgresql:5432/avatica'"
+ depends_on:
+ - postgresql
+ postgresql:
+ image: postgres:9.6
+ environment:
+ POSTGRES_DB: avatica
+ POSTGRES_USER: user
+ POSTGRES_PASSWORD: password
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/main/dockerhub/Dockerfile
----------------------------------------------------------------------
diff --git a/docker/src/main/dockerhub/Dockerfile b/docker/src/main/dockerhub/Dockerfile
new file mode 100644
index 0000000..4617a4e
--- /dev/null
+++ b/docker/src/main/dockerhub/Dockerfile
@@ -0,0 +1,38 @@
+# 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.
+
+FROM openjdk:8-jre-alpine
+MAINTAINER Apache Avatica <de...@calcite.apache.org>
+
+# Create an avatica user
+RUN addgroup -S avatica && adduser -S -G avatica avatica
+RUN mkdir -p /home/avatica/classpath
+
+# This line must be preserved. The Maven build will verify this version matches its version
+ARG AVATICA_VERSION="1.10.0"
+
+# Dependencies
+ADD https://repository.apache.org/content/groups/public/org/apache/calcite/avatica/avatica-standalone-server/${AVATICA_VERSION}/avatica-standalone-server-${AVATICA_VERSION}-shaded.jar /home/avatica/classpath
+
+# Make sure avatica owns its files
+RUN chown -R avatica: /home/avatica
+
+# Expose the default port as a convenience
+EXPOSE 8765
+
+# TODO Would like to do this, but screws up downstream due to https://github.com/docker/docker/issues/6119
+# USER avatica
+
+ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer", "-p", "8765"]
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy
----------------------------------------------------------------------
diff --git a/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy b/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy
new file mode 100644
index 0000000..2908be2
--- /dev/null
+++ b/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+
+System.out.println("Verifying the included version in the Dockerhub Dockerfile");
+
+String expectedPrefix = "ARG AVATICA_VERSION=";
+String expectedVersion = project.getVersion();
+
+if (null == expectedVersion) {
+ throw new IllegalArgumentException("Did not find Maven project version");
+}
+
+String dockerfilePath = "src/main/dockerhub/Dockerfile";
+File dockerfile = new File(basedir, dockerfilePath);
+if (!dockerfile.isFile()) {
+ throw new FileNotFoundException("Could not file dockerhub Dockerfile at " + dockerfilePath);
+}
+
+List<String> lines = Files.readAllLines(dockerfile.toPath());
+for (String line : lines) {
+ line = line.trim();
+ if (line.startsWith(expectedPrefix)) {
+ String value = line.substring(expectedPrefix.length());
+ // Trim leading and trailing quotation marks
+ value = value.substring(1, value.length() - 1);
+ if (expectedVersion.equals(value)) {
+ System.out.println("Found expected version in DockerHub dockerfile of " + value);
+ return true;
+ } else {
+ throw new IllegalArgumentException("Expected Avatica version of " + expectedVersion + " but got " + value);
+ }
+ }
+}
+
+throw new IllegalArgumentException("Could not extract Avatica version from " + dockerfile);
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0104fb0..5286c5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,6 +103,7 @@ limitations under the License.
<modules>
<module>core</module>
+ <module>docker</module>
<module>metrics</module>
<module>metrics-dropwizardmetrics3</module>
<module>noop-driver</module>
@@ -152,6 +153,11 @@ limitations under the License.
</dependency>
<dependency>
<groupId>org.apache.calcite.avatica</groupId>
+ <artifactId>avatica-standalone-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
@@ -520,6 +526,11 @@ limitations under the License.
</dependencies>
</plugin>
<plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.4.13</version>
+ </plugin>
+ <plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
<version>${forbiddenapis.version}</version>
@@ -591,6 +602,11 @@ limitations under the License.
<version>${build-helper-maven-plugin.version}</version>
</plugin>
<plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>${javacc-maven-plugin.version}</version>
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/site/_data/docs.yml
----------------------------------------------------------------------
diff --git a/site/_data/docs.yml b/site/_data/docs.yml
index 276edad..7c0a0ff 100644
--- a/site/_data/docs.yml
+++ b/site/_data/docs.yml
@@ -29,6 +29,7 @@
- security
- compatibility
- custom_client_artifacts
+ - docker
- title: Meta
docs:
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/site/_docs/docker_images.md
----------------------------------------------------------------------
diff --git a/site/_docs/docker_images.md b/site/_docs/docker_images.md
new file mode 100644
index 0000000..46976f7
--- /dev/null
+++ b/site/_docs/docker_images.md
@@ -0,0 +1,151 @@
+---
+layout: docs
+title: Docker Images
+sidebar_title: Docker Images
+permalink: /docs/docker.html
+---
+
+<!--
+{% comment %}
+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.
+{% endcomment %}
+-->
+
+## Docker Images for Avatica
+
+[Docker](https://en.wikipedia.org/wiki/Docker_(software)) is a popular piece of
+software that enables other software to run "anywhere". In the context of Avatica,
+we can use Docker to enable a run-anywhere Avatica server. These Docker containers
+can be used to easily create a server for the development of custom Avatica clients
+or encapsulating database access for testing software that uses Avatica.
+
+### Base "avatica-server" Docker Image
+
+Starting with the Avatica 1.10.0 release, Avatica is providing a number of Docker
+containers. Each of these images is based on a "parent" "avatica-server" Docker image.
+
+This Docker image has no bindings to a specific database (it has not database-specific
+JDBC driver included). It only contains a Java runtime and the Avatica Standalone Server
+jar (which contains all the necessary dependencies of the Avatica server). This docker
+image is not directly useful for end users; it is useful for those who want to use Avatica
+with a database of their choosing.
+
+This Docker image will be deployed to the [Apache Dockerhub account](https://hub.docker.com/r/apache/) after the release
+of 1.10.0 and will be updated for future releases of Avatica.
+
+### Database-specific Docker Images
+
+To make the lives of end-users who want to use a specific database easier, some Docker
+images are provided for some common databases. The current databases include:
+
+* [HyperSQL](http://hsqldb.org) (2.3.1)
+* [MySQL](https://www.mysql.com/) (Client 5.1.41, supports MySQL server 4.1, 5.0, 5.1, 5.5, 5.6, 5.7)
+* [PostgreSQL](https://www.postgresql.org/) (Client 42.0.0, supports PostgreSQL servers >=8.3)
+
+These images are not deployed as the licensing on each database driver is varied. Please
+understand and accept the license of each before using in any software project.
+
+Each of these images include a `build.sh` script which will build the docker image using
+the latest `avatica-server` Docker image. The resulting Docker image will be named according
+to the following format: `avatica-<database>-server`. For example, `avatica-hsqldb-server`,
+`avatica-mysql-server`, and `avatica-postgresql-server`.
+
+Additionally, [Docker Compose](https://github.com/docker/compose) configuration files for the above
+databases (sans HyperSQL) are provided which configure the database's standard Docker image
+and then connect Avatica to that Docker container. For example, the PostgreSQL docker-compose configuration
+file will start an instance of PostgreSQL and an instance of the Avatica server, each in their own container,
+exposing an Avatica server configured against a "real" PostgreSQL database.
+
+All of the `Dockerfile` and `docker-compose.yml` files are conveniently provided in an archive for
+each release, starting with 1.10.0.
+
+```
+avatica-docker-1.10.0-SNAPSHOT/
+avatica-docker-1.10.0-SNAPSHOT/hypersql/
+avatica-docker-1.10.0-SNAPSHOT/mysql/
+avatica-docker-1.10.0-SNAPSHOT/postgresql/
+avatica-docker-1.10.0-SNAPSHOT/Dockerfile
+avatica-docker-1.10.0-SNAPSHOT/hypersql/build.sh
+avatica-docker-1.10.0-SNAPSHOT/hypersql/Dockerfile
+avatica-docker-1.10.0-SNAPSHOT/mysql/build.sh
+avatica-docker-1.10.0-SNAPSHOT/mysql/docker-compose.yml
+avatica-docker-1.10.0-SNAPSHOT/mysql/Dockerfile
+avatica-docker-1.10.0-SNAPSHOT/postgresql/build.sh
+avatica-docker-1.10.0-SNAPSHOT/postgresql/docker-compose.yml
+avatica-docker-1.10.0-SNAPSHOT/postgresql/Dockerfile
+```
+
+#### Running
+
+Each of the provided database-specific Docker images set an `ENTRYPOINT` which
+encapsulate most of the Java command. The following options are available to specify:
+
+```
+Usage: <main class> [options]
+ Options:
+ -h, -help, --help
+ Print the help message
+ Default: false
+ -p, --port
+ Port the server should bind
+ Default: 0
+ -s, --serialization
+ Serialization method to use
+ Default: PROTOBUF
+ Possible Values: [JSON, PROTOBUF]
+ * -u, --url
+ JDBC driver url for the server
+```
+
+For example, to connect to a MySQL server, the following could be used:
+
+```
+$ ./avatica-docker-*/mysql/build.sh
+$ docker run --rm -it avatica-mysql-server \
+ -u jdbc:mysql://<fqdn>:3306/my_database
+```
+
+To debug these docker images, the `ENTRYPOINT` can be overriden to launch a shell
+
+```
+$ docker run --rm --entrypoint='' -it avatica-mysql-server /bin/sh
+```
+
+### Running Docker containers for custom databases
+
+The provided `avatica-server` Docker image is designed to be generally reusable
+for developers that want to expose a database of their choosing. A custom Dockerfile
+can be created by copying what the `avatica-mysql-server` or `avatica-postgresql-server`
+do, but this is also achievable via the Docker volumes.
+
+For example, consider we have a JAR with a JDBC driver for our database on our local
+machine `/home/user/my-database-jars/my-database-jdbc-1.0.jar`. We can run the following command to
+launch a custom Avatica server against our database with this JDBC driver.
+
+```
+$ docker run --rm -p 8765:8765 \
+ -v /home/user/my-database-jars/:/my-database-jars --entrypoint="" -it avatica-server \
+ /usr/bin/java -cp "/home/avatica/classpath/*:/my-database-jars/*" \
+ org.apache.calcite.avatica.standalone.StandaloneServer -p 8765 \
+ -u "jdbc:my_jdbc_url"
+```
+
+This command does the following:
+
+* Exposes the internal port 8765 on the local machine as 8765
+* Maps the local directory "home/user/my-database-jars" to the Docker container at "/my-database-jars" using the Docker volumes feature
+* Adds that mapped directory to the Java classpath
+* Sets the correct JDBC URL for the database
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/standalone-server/pom.xml
----------------------------------------------------------------------
diff --git a/standalone-server/pom.xml b/standalone-server/pom.xml
index e8c7f43..9f14964 100644
--- a/standalone-server/pom.xml
+++ b/standalone-server/pom.xml
@@ -23,8 +23,8 @@ limitations under the License.
<version>1.10.0-SNAPSHOT</version>
</parent>
<artifactId>avatica-standalone-server</artifactId>
- <name>Avatica Standalone Server</name>
- <description>A Stadnalone Avatica Server Implementation</description>
+ <name>Apache Calcite Avatica Standalone Server</name>
+ <description>A Standalone Avatica Server Implementation</description>
<properties>
<top.dir>${project.basedir}/..</top.dir>
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/c43aec54/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
----------------------------------------------------------------------
diff --git a/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java b/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
index f658f5e..0481f19 100644
--- a/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
+++ b/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
@@ -49,6 +49,10 @@ public class StandaloneServer {
description = "Serialization method to use", converter = SerializationConverter.class)
private Serialization serialization = Serialization.PROTOBUF;
+ @Parameter(names = { "-h", "-help", "--help" }, required = false, help = true,
+ description = "Print the help message")
+ private boolean help = false;
+
private HttpServer server;
public void start() {
@@ -92,7 +96,12 @@ public class StandaloneServer {
public static void main(String[] args) {
final StandaloneServer server = new StandaloneServer();
- new JCommander(server, args);
+ JCommander jc = new JCommander(server, args);
+ if (server.help) {
+ jc.usage();
+ Unsafe.systemExit(ExitCodes.USAGE.ordinal());
+ return;
+ }
server.start();
@@ -131,7 +140,8 @@ public class StandaloneServer {
private enum ExitCodes {
NORMAL,
ALREADY_STARTED, // 1
- START_FAILED; // 2
+ START_FAILED, // 2
+ USAGE; // 3
}
}