Repository: calcite-avatica Updated Branches: refs/heads/docker [created] ae972bdd8
[CALCITE-1364] Docker images for an avatica server Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica/commit/ba02fea0 Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica/tree/ba02fea0 Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica/diff/ba02fea0 Branch: refs/heads/docker Commit: ba02fea0b83039daa091278718feb59e6ea1957d Parents: c42a017 Author: Josh Elser <[email protected]> Authored: Sun Mar 26 14:50:29 2017 -0400 Committer: Josh Elser <[email protected]> Committed: Tue Apr 4 14:43:05 2017 -0400 ---------------------------------------------------------------------- docker/README.md | 46 ++++++++++ docker/pom.xml | 94 ++++++++++++++++++++ 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 +++++ docker/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 | 33 +++++++ pom.xml | 6 ++ 13 files changed, 428 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/docker/README.md ---------------------------------------------------------------------- diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..b2332cf --- /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 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. http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/docker/pom.xml ---------------------------------------------------------------------- diff --git a/docker/pom.xml b/docker/pom.xml new file mode 100644 index 0000000..8b28900 --- /dev/null +++ b/docker/pom.xml @@ -0,0 +1,94 @@ +<?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> + + <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.build.version}</imageTag> + <imageTag>latest</imageTag> + </imageTags> + <resources> + <resource> + <targetPath>/</targetPath> + <directory>${top.dir}/standalone-server/target</directory> + <include>avatica-standalone-server-${project.build.version}-shaded.jar</include> + </resource> + </resources> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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/ba02fea0/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..46cea22 --- /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 <[email protected]> + +# 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 http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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..5d261dd --- /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 <[email protected]> + +# 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"] http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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..7c0f342 --- /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 <[email protected]> + +# 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"] http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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/ba02fea0/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..203b07e --- /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 http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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..5ef523b --- /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 <[email protected]> + +# 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"] http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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/ba02fea0/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..05d2db9 --- /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 http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/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..12bb196 --- /dev/null +++ b/docker/src/main/dockerhub/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 <[email protected]> + +# Create an avatica user +RUN useradd -m avatica +RUN mkdir -p /home/avatica/classpath + +# Dependencies +ADD https://repository.apache.org/content/groups/public/org/apache/calcite/avatica/avatica-standalone-server/1.10.0/avatica-standalone-server-1.10.0-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 http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/ba02fea0/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 0104fb0..075c262 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> @@ -520,6 +521,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>
