blob: 66446e0628c89184d6b09083abfa3c096afcc394 [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Docker Images</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Jekyll v3.7.3">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic,900">
<link rel="stylesheet" href="/avatica/css/screen.css">
<link rel="icon" type="image/x-icon" href="/avatica/favicon.ico">
<!--[if lt IE 9]>
<script src="/js/html5shiv.min.js"></script>
<script src="/js/respond.min.js"></script>
<![endif]-->
</head>
<body class="wrap">
<header role="banner">
<nav class="mobile-nav show-on-mobiles">
<ul>
<li class="">
<a href="/avatica/">Home</a>
</li>
<li class="">
<a href="/avatica/downloads/">Download</a>
</li>
<li class="">
<a href="/avatica/community/">Community</a>
</li>
<li class="">
<a href="/avatica/develop/">Develop</a>
</li>
<li class="">
<a href="/avatica/news/">News</a>
</li>
<li class="current">
<a href="/avatica/docs/">Docs</a>
</li>
</ul>
</nav>
<div class="grid">
<div class="unit one-third center-on-mobiles">
<h1>
<a href="/avatica/">
<span class="sr-only">Apache Calcite Avatica</span>
<img src="/avatica/img/logo.png" width="226" height="140" alt="Calcite Logo">
</a>
</h1>
</div>
<nav class="main-nav unit two-thirds hide-on-mobiles">
<ul>
<li class="">
<a href="/avatica/">Home</a>
</li>
<li class="">
<a href="/avatica/downloads/">Download</a>
</li>
<li class="">
<a href="/avatica/community/">Community</a>
</li>
<li class="">
<a href="/avatica/develop/">Develop</a>
</li>
<li class="">
<a href="/avatica/news/">News</a>
</li>
<li class="current">
<a href="/avatica/docs/">Docs</a>
</li>
</ul>
</nav>
</div>
</header>
<section class="docs">
<div class="grid">
<div class="docs-nav-mobile unit whole show-on-mobiles">
<select onchange="if (this.value) window.location.href=this.value">
<option value="">Navigate the docs…</option>
<optgroup label="Overview">
</optgroup>
<optgroup label="Avatica Reference">
</optgroup>
<optgroup label="Avatica Go Client Reference">
</optgroup>
<optgroup label="Avatica Meta">
</optgroup>
<optgroup label="Avatica Go Client Meta">
</optgroup>
</select>
</div>
<div class="unit four-fifths">
<article>
<h1>Docker Images</h1>
<!--
-->
<h2 id="docker-images-for-avatica">Docker Images for Avatica</h2>
<p><a href="https://en.wikipedia.org/wiki/Docker_(software)">Docker</a> 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.</p>
<h3 id="base-avatica-server-docker-image">Base “avatica-server” Docker Image</h3>
<p>Avatica provides a number of Docker
containers. Each of these images is based on a “parent” “avatica-server” Docker image.</p>
<p>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.</p>
<p>This Docker image is deployed to the <a href="https://hub.docker.com/r/apache/calcite-avatica">Apache Docker Hub account</a>
and is updated for each release of Avatica.</p>
<h3 id="database-specific-docker-images">Database-specific Docker Images</h3>
<p>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:</p>
<ul>
<li><a href="http://hsqldb.org">HyperSQL</a> (2.3.1)</li>
<li><a href="https://www.mysql.com/">MySQL</a> (Client 5.1.41, supports MySQL server 4.1, 5.0, 5.1, 5.5, 5.6, 5.7)</li>
<li><a href="https://www.postgresql.org/">PostgreSQL</a> (Client 42.0.0, supports PostgreSQL servers &gt;=8.3)</li>
</ul>
<p>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.</p>
<p>Each of these images include a <code class="highlighter-rouge">build.sh</code> script which will build the docker image using
the latest <code class="highlighter-rouge">avatica-server</code> Docker image. The resulting Docker image will be named according
to the following format: <code class="highlighter-rouge">avatica-&lt;database&gt;-server</code>. For example, <code class="highlighter-rouge">avatica-hsqldb-server</code>,
<code class="highlighter-rouge">avatica-mysql-server</code>, and <code class="highlighter-rouge">avatica-postgresql-server</code>.</p>
<p>Additionally, <a href="https://github.com/docker/compose">Docker Compose</a> 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.</p>
<p>All of the <code class="highlighter-rouge">Dockerfile</code> and <code class="highlighter-rouge">docker-compose.yml</code> files are conveniently provided in an archive for
each release. Here is the layout for release 1.15.0:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>avatica-docker-1.15.0/
avatica-docker-1.15.0/hypersql/
avatica-docker-1.15.0/mysql/
avatica-docker-1.15.0/postgresql/
avatica-docker-1.15.0/Dockerfile
avatica-docker-1.15.0/hypersql/build.sh
avatica-docker-1.15.0/hypersql/Dockerfile
avatica-docker-1.15.0/mysql/build.sh
avatica-docker-1.15.0/mysql/docker-compose.yml
avatica-docker-1.15.0/mysql/Dockerfile
avatica-docker-1.15.0/postgresql/build.sh
avatica-docker-1.15.0/postgresql/docker-compose.yml
avatica-docker-1.15.0/postgresql/Dockerfile
</code></pre></div></div>
<h4 id="running">Running</h4>
<p>Each of the provided database-specific Docker images set an <code class="highlighter-rouge">ENTRYPOINT</code> which
encapsulate most of the Java command. The following options are available to specify:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Usage: &lt;main class&gt; [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
</code></pre></div></div>
<p>For example, to connect to a MySQL server, the following could be used:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ./avatica-docker-*/mysql/build.sh
$ docker run --rm -it avatica-mysql-server \
-u jdbc:mysql://&lt;fqdn&gt;:3306/my_database
</code></pre></div></div>
<p>To debug these docker images, the <code class="highlighter-rouge">ENTRYPOINT</code> can be overriden to launch a shell</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ docker run --rm --entrypoint='' -it avatica-mysql-server /bin/sh
</code></pre></div></div>
<h3 id="running-docker-containers-for-custom-databases">Running Docker containers for custom databases</h3>
<p>The provided <code class="highlighter-rouge">avatica-server</code> 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 <code class="highlighter-rouge">avatica-mysql-server</code> or <code class="highlighter-rouge">avatica-postgresql-server</code>
do, but this is also achievable via the Docker volumes.</p>
<p>For example, consider we have a JAR with a JDBC driver for our database on our local
machine <code class="highlighter-rouge">/home/user/my-database-jars/my-database-jdbc-1.0.jar</code>. We can run the following command to
launch a custom Avatica server against our database with this JDBC driver.</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ 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"
</code></pre></div></div>
<p>This command does the following:</p>
<ul>
<li>Exposes the internal port 8765 on the local machine as 8765</li>
<li>Maps the local directory “home/user/my-database-jars” to the Docker container at “/my-database-jars” using the Docker volumes feature</li>
<li>Adds that mapped directory to the Java classpath</li>
<li>Sets the correct JDBC URL for the database</li>
</ul>
<div class="section-nav">
<div class="left align-right">
<a href="/avatica/docs/custom_client_artifacts.html" class="prev">Previous</a>
</div>
<div class="right align-left">
<a href="/avatica/docs/protocol_testing.html" class="next">Next</a>
</div>
</div>
<div class="clear"></div>
</article>
</div>
<div class="unit one-fifth hide-on-mobiles">
<aside>
<h4>Overview</h4>
<ul>
<li class=""><a href="/avatica/docs/index.html">Background</a></li>
<li class=""><a href="/avatica/docs/roadmap.html">Roadmap</a></li>
</ul>
<h4>Avatica Reference</h4>
<ul>
<li class=""><a href="/avatica/docs/client_reference.html">Client Reference</a></li>
<li class=""><a href="/avatica/docs/json_reference.html">JSON Reference</a></li>
<li class=""><a href="/avatica/docs/protobuf_reference.html">Protobuf Reference</a></li>
<li class=""><a href="/avatica/docs/howto.html">HOWTO</a></li>
<li class=""><a href="/avatica/docs/security.html">Security</a></li>
<li class=""><a href="/avatica/docs/compatibility.html">Compatibility</a></li>
<li class=""><a href="/avatica/docs/custom_client_artifacts.html">Custom Client Artifacts</a></li>
<li class="current"><a href="/avatica/docs/docker.html">Docker Images</a></li>
<li class=""><a href="/avatica/docs/protocol_testing.html">Protocol Testing</a></li>
</ul>
<h4>Avatica Go Client Reference</h4>
<ul>
<li class=""><a href="/avatica/docs/go_client_reference.html">Go Client Reference</a></li>
<li class=""><a href="/avatica/docs/go_howto.html">HOWTO</a></li>
</ul>
<h4>Avatica Meta</h4>
<ul>
<li class=""><a href="/avatica/docs/history.html">History</a></li>
<li class=""><a href="/avatica/docs/api/">API</a></li>
<li class=""><a href="/avatica/docs/testapi/">Test API</a></li>
</ul>
<h4>Avatica Go Client Meta</h4>
<ul>
<li class=""><a href="/avatica/docs/go_history.html">Go Client History</a></li>
</ul>
</aside>
</div>
<div class="clear"></div>
</div>
</section>
<footer role="contentinfo">
<div id="poweredby">
<a href="http://www.apache.org/">
<span class="sr-only">Apache</span>
<img src="/avatica/img/feather.png" width="190" height="77" alt="Apache Logo"></a>
</div>
<div id="copyright">
<p>The contents of this website are &copy;&nbsp;2019
<a href="https://www.apache.org/">Apache Software Foundation</a>
under the terms of
the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">
Apache&nbsp;License&nbsp;v2</a>. Apache Calcite and its logo are
trademarks of the Apache Software Foundation.</p>
</div>
</footer>
<script>
var anchorForId = function (id) {
var anchor = document.createElement("a");
anchor.className = "header-link";
anchor.href = "#" + id;
anchor.innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>";
anchor.title = "Permalink";
return anchor;
};
var linkifyAnchors = function (level, containingElement) {
var headers = containingElement.getElementsByTagName("h" + level);
for (var h = 0; h < headers.length; h++) {
var header = headers[h];
if (typeof header.id !== "undefined" && header.id !== "") {
header.appendChild(anchorForId(header.id));
}
}
};
document.onreadystatechange = function () {
if (this.readyState === "complete") {
var contentBlock = document.getElementsByClassName("docs")[0] || document.getElementsByClassName("news")[0];
if (!contentBlock) {
return;
}
for (var level = 1; level <= 6; level++) {
linkifyAnchors(level, contentBlock);
}
}
};
</script>
</body>
</html>