From 7af7ff57494f59fd15cf896efea825326f78a3af Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Sun, 26 Mar 2017 14:50:29 -0400 Subject: [PATCH 01/17] [CALCITE-1364] Docker images for an avatica server * Includes a base Docker image for an Avatica server * 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 --- docker/README.md | 46 +++++++ docker/pom.xml | 118 ++++++++++++++++++ docker/src/assembly/docker-files.xml | 35 ++++++ docker/src/main/docker/Dockerfile | 33 +++++ docker/src/main/docker/hypersql/Dockerfile | 23 ++++ docker/src/main/docker/mysql/Dockerfile | 24 ++++ docker/src/main/docker/mysql/build.sh | 20 +++ .../src/main/docker/mysql/docker-compose.yml | 35 ++++++ docker/src/main/docker/postgresql/Dockerfile | 24 ++++ docker/src/main/docker/postgresql/build.sh | 20 +++ .../main/docker/postgresql/docker-compose.yml | 35 ++++++ docker/src/main/dockerhub/Dockerfile | 36 ++++++ ...verify-dockerhub-dockerfile-version.groovy | 53 ++++++++ pom.xml | 11 ++ 14 files changed, 513 insertions(+) create mode 100644 docker/README.md create mode 100644 docker/pom.xml create mode 100644 docker/src/assembly/docker-files.xml create mode 100644 docker/src/main/docker/Dockerfile create mode 100644 docker/src/main/docker/hypersql/Dockerfile create mode 100644 docker/src/main/docker/mysql/Dockerfile create mode 100755 docker/src/main/docker/mysql/build.sh create mode 100644 docker/src/main/docker/mysql/docker-compose.yml create mode 100644 docker/src/main/docker/postgresql/Dockerfile create mode 100755 docker/src/main/docker/postgresql/build.sh create mode 100644 docker/src/main/docker/postgresql/docker-compose.yml create mode 100644 docker/src/main/dockerhub/Dockerfile create mode 100644 docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..b2332cfb22 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,46 @@ + + +This module contains a number of Docker images to ease testing of +Avatica clients against a known-server. + +## Docker + +`src/main/docker` contains a number of Docker images 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 Docker images must be built by hand. + +### Provided Images + +A number of Docker images 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. diff --git a/docker/pom.xml b/docker/pom.xml new file mode 100644 index 0000000000..39027a7cf1 --- /dev/null +++ b/docker/pom.xml @@ -0,0 +1,118 @@ + + + + 4.0.0 + + org.apache.calcite.avatica + avatica-parent + 1.10.0-SNAPSHOT + + + avatica-docker + pom + Apache Calcite Avatica Docker images + Docker images for the Avatica server + + + ${project.basedir}/.. + + + + + + maven-assembly-plugin + + + + binary-assembly + + single + + package + + + src/assembly/docker-files.xml + + + + + + + + + + + docker + + + + com.spotify + docker-maven-plugin + + + package + + build + + + + + avatica-server + ${project.basedir}/src/main/docker + + ${project.build.version} + latest + + + + / + ${top.dir}/standalone-server/target + avatica-standalone-server-${project.build.version}-shaded.jar + + + + + + + + + + apache-release + + + + org.codehaus.gmaven + groovy-maven-plugin + + + check-dockerhub-dockerfile-version + validate + + execute + + + ${project.basedir}/src/test/scripts/verify-dockerhub-dockerfile-version.groovy + + + + + + + + + diff --git a/docker/src/assembly/docker-files.xml b/docker/src/assembly/docker-files.xml new file mode 100644 index 0000000000..5bfcce5cb2 --- /dev/null +++ b/docker/src/assembly/docker-files.xml @@ -0,0 +1,35 @@ + + + + docker-files + + tar.gz + zip + + + + src/main/docker + + + ** + + + + diff --git a/docker/src/main/docker/Dockerfile b/docker/src/main/docker/Dockerfile new file mode 100644 index 0000000000..46cea22fa8 --- /dev/null +++ b/docker/src/main/docker/Dockerfile @@ -0,0 +1,33 @@ +# 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 +MAINTAINER Apache Avatica + +# Create an avatica user +RUN useradd -m avatica +RUN mkdir -p /home/avatica/classpath + +# Dependencies +ADD avatica-standalone-server-1.10.0-SNAPSHOT-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 diff --git a/docker/src/main/docker/hypersql/Dockerfile b/docker/src/main/docker/hypersql/Dockerfile new file mode 100644 index 0000000000..5d261dd95a --- /dev/null +++ b/docker/src/main/docker/hypersql/Dockerfile @@ -0,0 +1,23 @@ +# 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 + +# 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/2.3.1/hsqldb-2.3.1.jar /home/avatica/classpath/ + +ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer", "-u", "jdbc:hsqldb:res:scott"] diff --git a/docker/src/main/docker/mysql/Dockerfile b/docker/src/main/docker/mysql/Dockerfile new file mode 100644 index 0000000000..7c0f3420e6 --- /dev/null +++ b/docker/src/main/docker/mysql/Dockerfile @@ -0,0 +1,24 @@ +# 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 + +# Dependencies +ADD https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.41/mysql-connector-java-5.1.41.jar /home/avatica/classpath/ +RUN chown -R avatica: /home/avatica + +USER avatica +ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] diff --git a/docker/src/main/docker/mysql/build.sh b/docker/src/main/docker/mysql/build.sh new file mode 100755 index 0000000000..9aca34d09b --- /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 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 0000000000..203b07e647 --- /dev/null +++ b/docker/src/main/docker/mysql/docker-compose.yml @@ -0,0 +1,35 @@ +# 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 + image: avatica-mysql-server + command: "-u 'jdbc:mysql://mysql:3306/avatica' -p 8765" + depends_on: + - mysql + mysql: + image: mysql:5.7 + ports: + - "3306:3306" + environment: + MYSQL_ROOT_PASSWORD: avatica + MYSQL_DATABASE: avatica + MYSQL_USER: user + MYSQL_PASSWORD: password diff --git a/docker/src/main/docker/postgresql/Dockerfile b/docker/src/main/docker/postgresql/Dockerfile new file mode 100644 index 0000000000..5ef523ba8e --- /dev/null +++ b/docker/src/main/docker/postgresql/Dockerfile @@ -0,0 +1,24 @@ +# 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 + +# Dependencies +ADD https://repo1.maven.org/maven2/org/postgresql/postgresql/42.0.0.jre7/postgresql-42.0.0.jre7.jar /home/avatica/classpath/ +RUN chown -R avatica: /home/avatica + +USER avatica +ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] diff --git a/docker/src/main/docker/postgresql/build.sh b/docker/src/main/docker/postgresql/build.sh new file mode 100755 index 0000000000..e98efed034 --- /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 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 0000000000..05d2db9731 --- /dev/null +++ b/docker/src/main/docker/postgresql/docker-compose.yml @@ -0,0 +1,35 @@ +# 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 + image: avatica-postgresql-server + command: "-u 'jdbc:postgresql://postgresql:5432/avatica' -p 8765" + depends_on: + - postgresql + postgresql: + image: postgres:9.6 + ports: + # Default port for the docker image + - "5432:5432" + environment: + POSTGRES_DB: avatica + POSTGRES_USER: user + POSTGRES_PASSWORD: password diff --git a/docker/src/main/dockerhub/Dockerfile b/docker/src/main/dockerhub/Dockerfile new file mode 100644 index 0000000000..6e4a9cbc88 --- /dev/null +++ b/docker/src/main/dockerhub/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 +MAINTAINER Apache Avatica + +# Create an avatica user +RUN useradd -m 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 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 0000000000..2908be2dff --- /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 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); diff --git a/pom.xml b/pom.xml index 0104fb0ce7..445467e41c 100644 --- a/pom.xml +++ b/pom.xml @@ -103,6 +103,7 @@ limitations under the License. core + docker metrics metrics-dropwizardmetrics3 noop-driver @@ -519,6 +520,11 @@ limitations under the License. + + com.spotify + docker-maven-plugin + 0.4.13 + de.thetaphi forbiddenapis @@ -590,6 +596,11 @@ limitations under the License. build-helper-maven-plugin ${build-helper-maven-plugin.version} + + org.codehaus.gmaven + groovy-maven-plugin + 2.0 + org.codehaus.mojo javacc-maven-plugin From ecf486a2d66d453cb2c4edca5f3064fde45d9ea8 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Tue, 4 Apr 2017 18:09:55 -0400 Subject: [PATCH 02/17] Clean up the standalone-server pom and fix the project.version --- docker/pom.xml | 11 +++++++++-- pom.xml | 5 +++++ standalone-server/pom.xml | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docker/pom.xml b/docker/pom.xml index 39027a7cf1..98767363a6 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -30,8 +30,15 @@ limitations under the License. ${project.basedir}/.. + avatica-standalone-server-${project.build.version}-shaded.jar + + + org.apache.calcite.avatica + avatica-standalone-server + + @@ -75,14 +82,14 @@ limitations under the License. avatica-server ${project.basedir}/src/main/docker - ${project.build.version} + ${project.version} latest / ${top.dir}/standalone-server/target - avatica-standalone-server-${project.build.version}-shaded.jar + avatica-standalone-server-${project.version}-shaded.jar diff --git a/pom.xml b/pom.xml index 445467e41c..5286c5bc27 100644 --- a/pom.xml +++ b/pom.xml @@ -151,6 +151,11 @@ limitations under the License. avatica-server ${project.version} + + org.apache.calcite.avatica + avatica-standalone-server + ${project.version} + org.apache.calcite.avatica avatica-core diff --git a/standalone-server/pom.xml b/standalone-server/pom.xml index e8c7f43a02..9f149646f1 100644 --- a/standalone-server/pom.xml +++ b/standalone-server/pom.xml @@ -23,8 +23,8 @@ limitations under the License. 1.10.0-SNAPSHOT avatica-standalone-server - Avatica Standalone Server - A Stadnalone Avatica Server Implementation + Apache Calcite Avatica Standalone Server + A Standalone Avatica Server Implementation ${project.basedir}/.. From fdfb65d3ec457d68f71708d0d56c692a81eaf213 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 11:13:37 -0400 Subject: [PATCH 03/17] Switch over to the alpine-based images --- docker/src/main/docker/Dockerfile | 4 ++-- docker/src/main/docker/hypersql/Dockerfile | 2 +- docker/src/main/docker/mysql/Dockerfile | 2 +- docker/src/main/docker/postgresql/Dockerfile | 2 +- docker/src/main/dockerhub/Dockerfile | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docker/src/main/docker/Dockerfile b/docker/src/main/docker/Dockerfile index 46cea22fa8..614056f196 100644 --- a/docker/src/main/docker/Dockerfile +++ b/docker/src/main/docker/Dockerfile @@ -13,11 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM openjdk:8-jre +FROM openjdk:8-jre-alpine MAINTAINER Apache Avatica # Create an avatica user -RUN useradd -m avatica +RUN addgroup -S avatica && adduser -S -G avatica avatica RUN mkdir -p /home/avatica/classpath # Dependencies diff --git a/docker/src/main/docker/hypersql/Dockerfile b/docker/src/main/docker/hypersql/Dockerfile index 5d261dd95a..e949ad2479 100644 --- a/docker/src/main/docker/hypersql/Dockerfile +++ b/docker/src/main/docker/hypersql/Dockerfile @@ -20,4 +20,4 @@ MAINTAINER Apache Avatica 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/2.3.1/hsqldb-2.3.1.jar /home/avatica/classpath/ -ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer", "-u", "jdbc:hsqldb:res:scott"] +ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer", "-u", "jdbc:hsqldb:res:scott"] diff --git a/docker/src/main/docker/mysql/Dockerfile b/docker/src/main/docker/mysql/Dockerfile index 7c0f3420e6..671f1ac42d 100644 --- a/docker/src/main/docker/mysql/Dockerfile +++ b/docker/src/main/docker/mysql/Dockerfile @@ -21,4 +21,4 @@ ADD https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.41/mysql-conne RUN chown -R avatica: /home/avatica USER avatica -ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] +ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] diff --git a/docker/src/main/docker/postgresql/Dockerfile b/docker/src/main/docker/postgresql/Dockerfile index 5ef523ba8e..99be89bdd9 100644 --- a/docker/src/main/docker/postgresql/Dockerfile +++ b/docker/src/main/docker/postgresql/Dockerfile @@ -21,4 +21,4 @@ ADD https://repo1.maven.org/maven2/org/postgresql/postgresql/42.0.0.jre7/postgre RUN chown -R avatica: /home/avatica USER avatica -ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] +ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] diff --git a/docker/src/main/dockerhub/Dockerfile b/docker/src/main/dockerhub/Dockerfile index 6e4a9cbc88..ece628fcf9 100644 --- a/docker/src/main/dockerhub/Dockerfile +++ b/docker/src/main/dockerhub/Dockerfile @@ -13,11 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM openjdk:8-jre +FROM openjdk:8-jre-alpine MAINTAINER Apache Avatica # Create an avatica user -RUN useradd -m avatica +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 From b1571f5d41fdae9e9f1528e17d13d5efddd99071 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 13:32:07 -0400 Subject: [PATCH 04/17] Add a build.sh for the hsqldb docker image --- docker/src/main/docker/hypersql/build.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 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 0000000000..136080767a --- /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 From 713e2b9224103986c936d5424342ef54b0e1d769 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 13:32:28 -0400 Subject: [PATCH 05/17] Add a help command to the StandaloneServer --- .../calcite/avatica/standalone/StandaloneServer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 f658f5e376..3af0f92a06 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 void join() throws InterruptedException { 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(); + System.exit(1); + return; + } server.start(); From 26f9682029f66af4c5f86603f289d804654ff480 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 13:32:41 -0400 Subject: [PATCH 06/17] Add a page on docker images to the website --- site/_data/docs.yml | 1 + site/_docs/docker_images.md | 125 ++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 site/_docs/docker_images.md diff --git a/site/_data/docs.yml b/site/_data/docs.yml index 276edad440..7c0a0ff8d9 100644 --- a/site/_data/docs.yml +++ b/site/_data/docs.yml @@ -29,6 +29,7 @@ - security - compatibility - custom_client_artifacts + - docker - title: Meta docs: diff --git a/site/_docs/docker_images.md b/site/_docs/docker_images.md new file mode 100644 index 0000000000..4c340e47ad --- /dev/null +++ b/site/_docs/docker_images.md @@ -0,0 +1,125 @@ +--- +layout: docs +title: Docker Images +sidebar_title: Docker Images +permalink: /docs/docker.html +--- + + + +## 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/) (5.1.41) +* [PostgreSQL](https://www.postgresql.org/) (42.0) + +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--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:
[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://:3306/my_database -p 8765 +``` + +To debug these docker images, the `ENTRYPOINT` can be overriden to launch a shell + +``` +$ docker run --rm --entrypoint='' -it avatica-mysql-server /bin/sh +``` From 32a0f49f1df9af0aa54e734d524e78e57b362928 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 18:05:37 -0400 Subject: [PATCH 07/17] Remove unused property --- docker/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/pom.xml b/docker/pom.xml index 98767363a6..f555ab9088 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -30,7 +30,6 @@ limitations under the License. ${project.basedir}/.. - avatica-standalone-server-${project.build.version}-shaded.jar From 93aeceed882d35de73d6eb699b998b759fea82ec Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 18:05:44 -0400 Subject: [PATCH 08/17] Use the already-created Unsafe call --- .../apache/calcite/avatica/standalone/StandaloneServer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 3af0f92a06..0481f19e52 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 @@ -99,7 +99,7 @@ public static void main(String[] args) { JCommander jc = new JCommander(server, args); if (server.help) { jc.usage(); - System.exit(1); + Unsafe.systemExit(ExitCodes.USAGE.ordinal()); return; } @@ -140,7 +140,8 @@ public static class SerializationConverter implements IStringConverter Date: Wed, 5 Apr 2017 18:06:54 -0400 Subject: [PATCH 09/17] Try to clarify the README --- docker/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/README.md b/docker/README.md index b2332cfb22..2633a9c061 100644 --- a/docker/README.md +++ b/docker/README.md @@ -17,25 +17,25 @@ limitations under the License. {% endcomment %} --> -This module contains a number of Docker images to ease testing of +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 Docker images and Docker-compose +`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 Docker images must be built by hand. +The other Dockerfiles must be built by hand. ### Provided Images -A number of Docker images for different databases are provided. Presently, they include: +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) +* [PostgreSQL](https://github.com/apache/calcite-avatica/tree/master/docker/src/main/docker/postgresql) ## Dockerhub From cf17635063a882baa60264586f79d06e02187454 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Wed, 5 Apr 2017 18:34:08 -0400 Subject: [PATCH 10/17] Add the build tag to the avatica server dockerfile --- docker/src/main/docker/mysql/docker-compose.yml | 3 +-- docker/src/main/docker/postgresql/docker-compose.yml | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docker/src/main/docker/mysql/docker-compose.yml b/docker/src/main/docker/mysql/docker-compose.yml index 203b07e647..eddb03fe04 100644 --- a/docker/src/main/docker/mysql/docker-compose.yml +++ b/docker/src/main/docker/mysql/docker-compose.yml @@ -20,14 +20,13 @@ services: - "8765:8765" links: - mysql + build: ./ image: avatica-mysql-server command: "-u 'jdbc:mysql://mysql:3306/avatica' -p 8765" depends_on: - mysql mysql: image: mysql:5.7 - ports: - - "3306:3306" environment: MYSQL_ROOT_PASSWORD: avatica MYSQL_DATABASE: avatica diff --git a/docker/src/main/docker/postgresql/docker-compose.yml b/docker/src/main/docker/postgresql/docker-compose.yml index 05d2db9731..8fc4977d5c 100644 --- a/docker/src/main/docker/postgresql/docker-compose.yml +++ b/docker/src/main/docker/postgresql/docker-compose.yml @@ -20,15 +20,14 @@ services: - "8765:8765" links: - postgresql + build: ./ image: avatica-postgresql-server + # Default port for the docker image command: "-u 'jdbc:postgresql://postgresql:5432/avatica' -p 8765" depends_on: - postgresql postgresql: image: postgres:9.6 - ports: - # Default port for the docker image - - "5432:5432" environment: POSTGRES_DB: avatica POSTGRES_USER: user From bda16c1331e0196cc59ab90294a835e0b28ed8c6 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 12:14:14 -0400 Subject: [PATCH 11/17] Some more consolidation/simplification as recommended by Kevin --- docker/src/main/docker/Dockerfile | 4 ++++ docker/src/main/docker/hypersql/Dockerfile | 7 +++++-- docker/src/main/docker/mysql/Dockerfile | 5 +++-- docker/src/main/docker/postgresql/Dockerfile | 5 +++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docker/src/main/docker/Dockerfile b/docker/src/main/docker/Dockerfile index 614056f196..eafad64f82 100644 --- a/docker/src/main/docker/Dockerfile +++ b/docker/src/main/docker/Dockerfile @@ -21,6 +21,7 @@ RUN addgroup -S avatica && adduser -S -G avatica avatica RUN mkdir -p /home/avatica/classpath # Dependencies +# TODO would be nice to remove the hard-coded version ADD avatica-standalone-server-1.10.0-SNAPSHOT-shaded.jar /home/avatica/classpath # Make sure avatica owns its files @@ -28,6 +29,9 @@ 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"] diff --git a/docker/src/main/docker/hypersql/Dockerfile b/docker/src/main/docker/hypersql/Dockerfile index e949ad2479..a79dfa2c68 100644 --- a/docker/src/main/docker/hypersql/Dockerfile +++ b/docker/src/main/docker/hypersql/Dockerfile @@ -16,8 +16,11 @@ FROM avatica-server:latest MAINTAINER Apache Avatica +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/2.3.1/hsqldb-2.3.1.jar /home/avatica/classpath/ +ADD https://repo1.maven.org/maven2/org/hsqldb/hsqldb/${HSQLDB_VERSION}/hsqldb-${HSQLDB_VERSION}.jar /home/avatica/classpath/ -ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer", "-u", "jdbc:hsqldb:res:scott"] +# Add on to avatica-server's entrypoint +CMD ["-u", "jdbc:hsqldb:res:scott"] diff --git a/docker/src/main/docker/mysql/Dockerfile b/docker/src/main/docker/mysql/Dockerfile index 671f1ac42d..c8a5d5be41 100644 --- a/docker/src/main/docker/mysql/Dockerfile +++ b/docker/src/main/docker/mysql/Dockerfile @@ -16,9 +16,10 @@ FROM avatica-server:latest MAINTAINER Apache Avatica +ARG MYSQL_VERSION="5.1.41" + # Dependencies -ADD https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.41/mysql-connector-java-5.1.41.jar /home/avatica/classpath/ +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 -ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] diff --git a/docker/src/main/docker/postgresql/Dockerfile b/docker/src/main/docker/postgresql/Dockerfile index 99be89bdd9..e77200a315 100644 --- a/docker/src/main/docker/postgresql/Dockerfile +++ b/docker/src/main/docker/postgresql/Dockerfile @@ -16,9 +16,10 @@ FROM avatica-server:latest MAINTAINER Apache Avatica +ARG POSTGRESQL_VERSION="42.0.0.jre7" + # Dependencies -ADD https://repo1.maven.org/maven2/org/postgresql/postgresql/42.0.0.jre7/postgresql-42.0.0.jre7.jar /home/avatica/classpath/ +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 -ENTRYPOINT ["/usr/bin/java", "-cp", "/home/avatica/classpath/*", "org.apache.calcite.avatica.standalone.StandaloneServer"] From 9740fe436e94ceb4658267dc1cb0662e96d71a59 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 12:30:54 -0400 Subject: [PATCH 12/17] Extra updates to the new docker page on the website * Clarifies client/server compatibility provided dockerfile * Adds a section on using `avatica-server` with a custom database --- site/_docs/docker_images.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/site/_docs/docker_images.md b/site/_docs/docker_images.md index 4c340e47ad..b17fea841f 100644 --- a/site/_docs/docker_images.md +++ b/site/_docs/docker_images.md @@ -52,8 +52,8 @@ To make the lives of end-users who want to use a specific database easier, some images are provided for some common databases. The current databases include: * [HyperSQL](http://hsqldb.org) (2.3.1) -* [MySQL](https://www.mysql.com/) (5.1.41) -* [PostgreSQL](https://www.postgresql.org/) (42.0) +* [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. @@ -123,3 +123,29 @@ To debug these docker images, the `ENTRYPOINT` can be overriden to launch a shel ``` $ 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 From 3a2ef295af05ab7c097073af24ae68282046b253 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 12:43:00 -0400 Subject: [PATCH 13/17] Use the java8 jar instead of java7 for pg --- docker/src/main/docker/postgresql/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/src/main/docker/postgresql/Dockerfile b/docker/src/main/docker/postgresql/Dockerfile index e77200a315..501f15de38 100644 --- a/docker/src/main/docker/postgresql/Dockerfile +++ b/docker/src/main/docker/postgresql/Dockerfile @@ -16,7 +16,7 @@ FROM avatica-server:latest MAINTAINER Apache Avatica -ARG POSTGRESQL_VERSION="42.0.0.jre7" +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/ From dce27016700225b7dc65c1b8baa42fb0dc08b059 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 12:44:13 -0400 Subject: [PATCH 14/17] Forgot to change these in the source tree. --- docker/src/main/docker/mysql/docker-compose.yml | 2 +- docker/src/main/docker/postgresql/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/src/main/docker/mysql/docker-compose.yml b/docker/src/main/docker/mysql/docker-compose.yml index eddb03fe04..c20eaf5155 100644 --- a/docker/src/main/docker/mysql/docker-compose.yml +++ b/docker/src/main/docker/mysql/docker-compose.yml @@ -22,7 +22,7 @@ services: - mysql build: ./ image: avatica-mysql-server - command: "-u 'jdbc:mysql://mysql:3306/avatica' -p 8765" + command: "-u 'jdbc:mysql://mysql:3306/avatica'" depends_on: - mysql mysql: diff --git a/docker/src/main/docker/postgresql/docker-compose.yml b/docker/src/main/docker/postgresql/docker-compose.yml index 8fc4977d5c..a4f1c8bfcb 100644 --- a/docker/src/main/docker/postgresql/docker-compose.yml +++ b/docker/src/main/docker/postgresql/docker-compose.yml @@ -23,7 +23,7 @@ services: build: ./ image: avatica-postgresql-server # Default port for the docker image - command: "-u 'jdbc:postgresql://postgresql:5432/avatica' -p 8765" + command: "-u 'jdbc:postgresql://postgresql:5432/avatica'" depends_on: - postgresql postgresql: From 9d1b84fb4fdf64e5ca6a6ca9e1da72588e140f52 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 13:05:22 -0400 Subject: [PATCH 15/17] Use globbing to add the shaded jar and add missing ENTRYPOINT to dockerhub file --- docker/src/main/docker/Dockerfile | 2 +- docker/src/main/dockerhub/Dockerfile | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/src/main/docker/Dockerfile b/docker/src/main/docker/Dockerfile index eafad64f82..6a6fbf3003 100644 --- a/docker/src/main/docker/Dockerfile +++ b/docker/src/main/docker/Dockerfile @@ -22,7 +22,7 @@ RUN mkdir -p /home/avatica/classpath # Dependencies # TODO would be nice to remove the hard-coded version -ADD avatica-standalone-server-1.10.0-SNAPSHOT-shaded.jar /home/avatica/classpath +ADD avatica-standalone-server-*-shaded.jar /home/avatica/classpath # Make sure avatica owns its files RUN chown -R avatica: /home/avatica diff --git a/docker/src/main/dockerhub/Dockerfile b/docker/src/main/dockerhub/Dockerfile index ece628fcf9..4617a4ebf4 100644 --- a/docker/src/main/dockerhub/Dockerfile +++ b/docker/src/main/dockerhub/Dockerfile @@ -34,3 +34,5 @@ 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"] From c8dfeaa04ffa78f490e380b0d37ac1f9b6340294 Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 13:05:51 -0400 Subject: [PATCH 16/17] Remove unnecessary argument from docs --- site/_docs/docker_images.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/_docs/docker_images.md b/site/_docs/docker_images.md index b17fea841f..46976f777c 100644 --- a/site/_docs/docker_images.md +++ b/site/_docs/docker_images.md @@ -115,7 +115,7 @@ 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://:3306/my_database -p 8765 + -u jdbc:mysql://:3306/my_database ``` To debug these docker images, the `ENTRYPOINT` can be overriden to launch a shell From 6c07c27999919a2bfacb7b650f91dd96654ac03e Mon Sep 17 00:00:00 2001 From: Josh Elser Date: Thu, 6 Apr 2017 13:32:27 -0400 Subject: [PATCH 17/17] Remove unnecessary TODO --- docker/src/main/docker/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/src/main/docker/Dockerfile b/docker/src/main/docker/Dockerfile index 6a6fbf3003..e5b48debe1 100644 --- a/docker/src/main/docker/Dockerfile +++ b/docker/src/main/docker/Dockerfile @@ -21,7 +21,6 @@ RUN addgroup -S avatica && adduser -S -G avatica avatica RUN mkdir -p /home/avatica/classpath # Dependencies -# TODO would be nice to remove the hard-coded version ADD avatica-standalone-server-*-shaded.jar /home/avatica/classpath # Make sure avatica owns its files