[CALCITE-2698] Use Docker Hub hooks to select Avatica version during image build and publish HSQLDB image
Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica/commit/1e4013e1 Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica/tree/1e4013e1 Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica/diff/1e4013e1 Branch: refs/heads/branch-avatica-1.13 Commit: 1e4013e16619824cbdf6bcd13846473a7c88f8e4 Parents: acc49bf Author: Francis Chuang <[email protected]> Authored: Fri Nov 23 09:37:05 2018 +1100 Committer: Francis Chuang <[email protected]> Committed: Thu Nov 29 08:18:52 2018 +1100 ---------------------------------------------------------------------- .travis.yml | 4 +- appveyor.yml | 4 +- docker.sh | 4 +- docker/pom.xml | 29 ---------- docker/src/main/dockerhub-hypersql/Dockerfile | 29 ---------- docker/src/main/dockerhub/Dockerfile | 3 +- docker/src/main/dockerhub/Dockerfile.hypersql | 29 ++++++++++ docker/src/main/dockerhub/hooks/build | 18 +++++++ docker/src/main/dockerhub/hooks/post_push | 21 ++++++++ .../verify-dockerhub-dockerfile-version.groovy | 56 -------------------- pom.xml | 6 --- site/_docs/howto.md | 20 ++++--- 12 files changed, 84 insertions(+), 139 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index a0c493f..053ef99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,12 +42,12 @@ before_install: - docker pull $IMAGE install: # Print the Maven version, skip tests and javadoc - - $DOCKERRUN $IMAGE mvn -V install -DskipTests -Dmaven.javadoc.skip=true -Djavax.net.ssl.trustStorePassword=changeit -DskipDockerCheck + - $DOCKERRUN $IMAGE mvn -V install -DskipTests -Dmaven.javadoc.skip=true -Djavax.net.ssl.trustStorePassword=changeit script: # Print surefire output to the console instead of files # Ensure that IBM JDK and Jetty work together - -Dcom.ibm.jsse2.overrideDefaultTLS=true - unset _JAVA_OPTIONS - - $DOCKERRUN $IMAGE mvn -Dsurefire.useFile=false -Djavax.net.ssl.trustStorePassword=changeit -Dcom.ibm.jsse2.overrideDefaultTLS=true -DskipDockerCheck verify javadoc:javadoc javadoc:test-javadoc + - $DOCKERRUN $IMAGE mvn -Dsurefire.useFile=false -Djavax.net.ssl.trustStorePassword=changeit -Dcom.ibm.jsse2.overrideDefaultTLS=true verify javadoc:javadoc javadoc:test-javadoc git: depth: 10000 sudo: required http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/appveyor.yml ---------------------------------------------------------------------- diff --git a/appveyor.yml b/appveyor.yml index cd397a2..09d78f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,9 +35,9 @@ environment: - JAVA_HOME: C:\Program Files\Java\jdk9 - JAVA_HOME: C:\Program Files\Java\jdk10 build_script: - - mvn clean -V install -DskipTests -Dmaven.javadoc.skip=true -Djavax.net.ssl.trustStorePassword=changeit -DskipDockerCheck + - mvn clean -V install -DskipTests -Dmaven.javadoc.skip=true -Djavax.net.ssl.trustStorePassword=changeit test_script: - - mvn -Dsurefire.useFile=false -Djavax.net.ssl.trustStorePassword=changeit verify javadoc:javadoc javadoc:test-javadoc -DskipDockerCheck + - mvn -Dsurefire.useFile=false -Djavax.net.ssl.trustStorePassword=changeit verify javadoc:javadoc javadoc:test-javadoc cache: - C:\maven\ - C:\Users\appveyor\.m2 http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/docker.sh ---------------------------------------------------------------------- diff --git a/docker.sh b/docker.sh index 56e8f2c..c66fbc3 100755 --- a/docker.sh +++ b/docker.sh @@ -242,7 +242,7 @@ case $1 in select_gpg_key get_build_configuration - mvn -Dmaven.artifact.threads=20 -DdryRun=true -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$DEV_VERSION-SNAPSHOT -Dtag="avatica-$RELEASE_VERSION-rc$RC_NUMBER" -Papache-release -Duser.name=$ASF_USERNAME release:prepare -Darguments="-DskipDockerCheck -Dgpg.keyname=$SELECTED_GPG_KEY" + mvn -Dmaven.artifact.threads=20 -DdryRun=true -DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$DEV_VERSION-SNAPSHOT -Dtag="avatica-$RELEASE_VERSION-rc$RC_NUMBER" -Papache-release -Duser.name=$ASF_USERNAME release:prepare -Darguments=-Dgpg.keyname=$SELECTED_GPG_KEY ;; release) @@ -264,7 +264,7 @@ case $1 in test) init_glibc - mvn clean verify -Dcheckstyle.skip -DskipDockerCheck + mvn clean verify -Dcheckstyle.skip ;; *) http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/docker/pom.xml ---------------------------------------------------------------------- diff --git a/docker/pom.xml b/docker/pom.xml index 5548499..d1819ed 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -96,34 +96,5 @@ limitations under the License. </plugins> </build> </profile> - <profile> - <!-- Need to verify that the URL we're pulling from in the Dockerfile is correct for this release --> - <id>check-dockerfile-version</id> - <activation> - <property> - <name>!skipDockerCheck</name> - </property> - </activation> - <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/1e4013e1/docker/src/main/dockerhub-hypersql/Dockerfile ---------------------------------------------------------------------- diff --git a/docker/src/main/dockerhub-hypersql/Dockerfile b/docker/src/main/dockerhub-hypersql/Dockerfile deleted file mode 100644 index 0ea57b3..0000000 --- a/docker/src/main/dockerhub-hypersql/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# 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. - -ARG AVATICA_VERSION=1.12.0 -FROM apache/calcite-avatica:$AVATICA_VERSION -MAINTAINER Apache Avatica <[email protected]> - -ARG HSQLDB_VERSION="2.4.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"] - -# End Dockerfile http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/docker/src/main/dockerhub/Dockerfile ---------------------------------------------------------------------- diff --git a/docker/src/main/dockerhub/Dockerfile b/docker/src/main/dockerhub/Dockerfile index 5308afa..f3a1004 100644 --- a/docker/src/main/dockerhub/Dockerfile +++ b/docker/src/main/dockerhub/Dockerfile @@ -20,8 +20,7 @@ MAINTAINER Apache Avatica <[email protected]> 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.12.0" +ARG AVATICA_VERSION # 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 http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/docker/src/main/dockerhub/Dockerfile.hypersql ---------------------------------------------------------------------- diff --git a/docker/src/main/dockerhub/Dockerfile.hypersql b/docker/src/main/dockerhub/Dockerfile.hypersql new file mode 100644 index 0000000..8c8c82c --- /dev/null +++ b/docker/src/main/dockerhub/Dockerfile.hypersql @@ -0,0 +1,29 @@ +# 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. + +ARG AVATICA_VERSION +FROM apache/calcite-avatica:$AVATICA_VERSION +MAINTAINER Apache Avatica <[email protected]> + +ARG HSQLDB_VERSION="2.4.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"] + +# End Dockerfile http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/docker/src/main/dockerhub/hooks/build ---------------------------------------------------------------------- diff --git a/docker/src/main/dockerhub/hooks/build b/docker/src/main/dockerhub/hooks/build new file mode 100644 index 0000000..cfc048d --- /dev/null +++ b/docker/src/main/dockerhub/hooks/build @@ -0,0 +1,18 @@ +#!/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. + +docker build --build-arg AVATICA_VERSION="$DOCKER_TAG" -t $IMAGE_NAME . \ No newline at end of file http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/docker/src/main/dockerhub/hooks/post_push ---------------------------------------------------------------------- diff --git a/docker/src/main/dockerhub/hooks/post_push b/docker/src/main/dockerhub/hooks/post_push new file mode 100644 index 0000000..c864128 --- /dev/null +++ b/docker/src/main/dockerhub/hooks/post_push @@ -0,0 +1,21 @@ +#!/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. + +HSQLDB_IMAGE_NAME=apache/calcite-avatica-hypersql:$DOCKER_TAG + +docker build --build-arg AVATICA_VERSION="$DOCKER_TAG" -f Dockerfile.hypersql -t $HSQLDB_IMAGE_NAME . +docker push $HSQLDB_IMAGE_NAME \ No newline at end of file http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/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 deleted file mode 100644 index da7d4f3..0000000 --- a/docker/src/test/scripts/verify-dockerhub-dockerfile-version.groovy +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 Docker Hub Dockerfile"); - -String expectedPrefix = "ARG AVATICA_VERSION="; -String expectedVersion = project.getVersion(); - -if (null == expectedVersion) { - throw new IllegalArgumentException("Did not find Maven project version"); -} - -def dockerfiles = ["src/main/dockerhub/Dockerfile", "src/main/dockerhub-hypersql/Dockerfile"] - -for (dockerfilePath in dockerfiles) { - 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/1e4013e1/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index f00b0d0..6197f0b 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,6 @@ limitations under the License. <docker-maven-plugin.version>1.1.1</docker-maven-plugin.version> <dropwizard-metrics.version>4.0.3</dropwizard-metrics.version> <forbiddenapis.version>2.6</forbiddenapis.version> - <groovy-maven-plugin.version>2.1</groovy-maven-plugin.version> <!-- We support guava versions as old as 14.0.1 (the version used by Hive) but prefer more recent versions. --> <guava.version>14.0.1</guava.version> @@ -621,11 +620,6 @@ limitations under the License. <version>${build-helper-maven-plugin.version}</version> </plugin> <plugin> - <groupId>org.codehaus.gmaven</groupId> - <artifactId>groovy-maven-plugin</artifactId> - <version>${groovy-maven-plugin.version}</version> - </plugin> - <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/1e4013e1/site/_docs/howto.md ---------------------------------------------------------------------- diff --git a/site/_docs/howto.md b/site/_docs/howto.md index c832731..1615cd1 100644 --- a/site/_docs/howto.md +++ b/site/_docs/howto.md @@ -67,15 +67,12 @@ tests. ## Running tests The test suite will run by default when you build, unless you specify -`-DskipTests`: - -Note: During development, you should include `-DskipDockerCheck`, because the docker check checks to see if the dockerfile -includes the correct version, which will fail unless you are making a release of Avatica. +`-DskipTests`. ### Running tests in your environment {% highlight bash %} -$ ./mvnw clean verify -Dcheckstyle.skip -DskipDockerCheck +$ ./mvnw clean verify -Dcheckstyle.skip {% endhighlight %} By default, invoking the `verify` Maven lifecycle phase will also cause checkstyle @@ -177,8 +174,7 @@ Before you start: * Set up signing keys as described above. * Make sure you are using JDK 8 (not 9 or 10). -* Check that `README`, `site/_docs/howto.md`, `site/_docs/docker_images.md`, - and `docker/src/main/dockerhub/Dockerfile` have the correct version number. +* Check that `README`, `site/_docs/howto.md`, `site/_docs/docker_images.md` have the correct version number. * Check that `NOTICE` has the current copyright year. * Set `version.major` and `version.minor` in `pom.xml`. * Add release notes to `site/_docs/history.md`. Include the commit history, @@ -227,10 +223,10 @@ git clean -xn # Typically we increment minor version: If X.Y.Z is 1.11.0, X2.Y2.Z2 is 1.12.0. # Note X.Y.Z is the current version we're trying to release, and X2.Y2.Z2 is the next development version. # For example, if I am currently building a release for 1.11.0, X.Y.Z would be 1.11.0 and X2.Y2.Z2 would be 1.12.0. -./mvnw -DdryRun=true -DreleaseVersion=X.Y.Z -DdevelopmentVersion=X2.Y2.Z2-SNAPSHOT -Dtag=avatica-X.Y.Z-rcN -Papache-release -Duser.name=${asf.username} release:prepare -Darguments=-DskipDockerCheck +./mvnw -DdryRun=true -DreleaseVersion=X.Y.Z -DdevelopmentVersion=X2.Y2.Z2-SNAPSHOT -Dtag=avatica-X.Y.Z-rcN -Papache-release -Duser.name=${asf.username} release:prepare # If you have multiple GPG keys, you can select the key used to sign the release by appending `-Dgpg.keyname=${your.key.id}` to `-Darguments`: -./mvnw -DdryRun=true -DreleaseVersion=X.Y.Z -DdevelopmentVersion=X2.Y2.Z2-SNAPSHOT -Dtag=avatica-X.Y.Z-rcN -Papache-release -Duser.name=${asf.username} release:prepare -Darguments="-DskipDockerCheck -Dgpg.keyname=${your.key.id}" +./mvnw -DdryRun=true -DreleaseVersion=X.Y.Z -DdevelopmentVersion=X2.Y2.Z2-SNAPSHOT -Dtag=avatica-X.Y.Z-rcN -Papache-release -Duser.name=${asf.username} release:prepare -Darguments=-Dgpg.keyname=${your.key.id} {% endhighlight %} ### To perform the dry-run in docker: @@ -511,6 +507,10 @@ Promote the staged nexus artifacts. * In the line with "orgapachecalcite-xxxx", check the box * Press "Release" button +Tip: Push the git tag only after the staged nexus artifacts are promoted in the repository. This is because pushing the +tag triggers Docker Hub to start building the docker images immediately and the build will pull in the promoted artifacts. +If the artifacts are not yet available, the build on Docker Hub will fail. + Copy the Git tag: {% highlight bash %} @@ -553,8 +553,6 @@ svn ci The old releases will remain available in the [release archive](http://archive.apache.org/dist/calcite/). -Publish the [Docker images](docker.html). - Add a release note by copying [site/_posts/2016-11-01-release-1.9.0.md]({{ site.sourceRoot }}/site/_posts/2016-11-01-release-1.9.0.md), generate the javadoc and copy to `site/target/avatica/apidocs`
