polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [2/2] polygene-java git commit: POLYGENE-221 Tidy up building Docker images for integration tests
Date Tue, 10 Jan 2017 22:17:35 GMT
POLYGENE-221 Tidy up building Docker images for integration tests

All images defined in the :internals:testsupport-internal project
alongside the DockerRule for JUnit.

Should now work on JDK 9.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/9b60364e
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/9b60364e
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/9b60364e

Branch: refs/heads/develop
Commit: 9b60364ef87aab7d9533a4eedc9c8f17eb62e39a
Parents: 4b51787
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Tue Jan 10 23:14:07 2017 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Tue Jan 10 23:14:07 2017 +0100

----------------------------------------------------------------------
 buildSrc/build.gradle                           |  2 +-
 .../distributions/DistributionsPlugin.groovy    |  1 +
 .../internals/InternalDockerPlugin.groovy       | 60 ++++++++++++++------
 internals/docker-memcached/build.gradle         | 19 -------
 .../docker-memcached/src/main/docker/Dockerfile |  1 -
 internals/docker-mysql/build.gradle             | 19 -------
 .../docker-mysql/src/main/docker/Dockerfile     |  1 -
 internals/docker-postgres/build.gradle          | 19 -------
 .../docker-postgres/src/main/docker/Dockerfile  |  2 -
 .../src/main/docker/init-test-db.sh             | 14 -----
 internals/docker-redis/build.gradle             | 19 -------
 .../docker-redis/src/main/docker/Dockerfile     |  1 -
 internals/testsupport-internal/build.gradle     |  8 +--
 .../src/main/docker/memcached/Dockerfile        |  1 +
 .../src/main/docker/mysql/Dockerfile            |  1 +
 .../src/main/docker/postgres/Dockerfile         |  2 +
 .../src/main/docker/postgres/init-test-db.sh    | 14 +++++
 .../src/main/docker/redis/Dockerfile            |  1 +
 settings.gradle                                 |  6 +-
 19 files changed, 66 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/buildSrc/build.gradle
----------------------------------------------------------------------
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 80a36a0..af68367 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -33,7 +33,7 @@ dependencies {
   compile 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
   compile 'org.apache.httpcomponents:httpclient:4.5.2'
   compile 'org.apache.httpcomponents:httpmime:4.5.2'
-  compile 'gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.9.2'
+  compile 'com.bmuschko:gradle-docker-plugin:3.0.5'
 
   testCompile 'junit:junit:4.12'
   testCompile( 'org.spockframework:spock-core:1.0-groovy-2.4' ) { exclude module: 'groovy-all'
}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
index 0deb84d..6af247a 100644
--- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy
@@ -126,6 +126,7 @@ class DistributionsPlugin implements Plugin<Project>
         def relPath = new File( project.rootProject.projectDir.toURI().relativize( p.projectDir.toURI()
).toString() )
         spec.include "$relPath/**"
       }
+      spec.include 'internals/**'
       spec.include 'manual/**'
       spec.include 'samples/**'
       spec.include 'tests/**'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/internals/InternalDockerPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/internals/InternalDockerPlugin.groovy
b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/internals/InternalDockerPlugin.groovy
index 7aed3d4..898a075 100644
--- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/internals/InternalDockerPlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/internals/InternalDockerPlugin.groovy
@@ -17,36 +17,62 @@
  */
 package org.apache.polygene.gradle.structure.internals
 
-import com.palantir.gradle.docker.DockerExtension
-import com.palantir.gradle.docker.PalantirDockerPlugin
+import com.bmuschko.gradle.docker.DockerExtension
+import com.bmuschko.gradle.docker.DockerRemoteApiPlugin
+import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
 import groovy.transform.CompileStatic
 import org.apache.polygene.gradle.BasePlugin
 import org.apache.polygene.gradle.code.PublishNaming
+import org.apache.polygene.gradle.dependencies.DependenciesPlugin
 import org.gradle.api.Plugin
 import org.gradle.api.Project
-import org.gradle.api.Task
-import org.gradle.language.base.plugins.LifecycleBasePlugin
 
 @CompileStatic
 class InternalDockerPlugin implements Plugin<Project>
 {
+  private final String dockerMachineName = System.getenv( 'DOCKER_MACHINE_NAME' )
+  private final String dockerHost = System.getenv( 'DOCKER_HOST' )
+  private final String dockerCertPath = System.getenv( 'DOCKER_CERT_PATH' )
+
   @Override
   void apply( Project project )
   {
     project.plugins.apply BasePlugin
-    project.plugins.apply PalantirDockerPlugin
-    def dockerExtension = project.extensions.getByType( DockerExtension )
-    dockerExtension.name = "org.apache.polygene:${ PublishNaming.publishedNameFor( project.path
) }"
-    dockerExtension.dockerfile = 'src/main/docker/Dockerfile'
-    dockerExtension.files 'src/main/docker'
-    def dockerHost = System.getenv( 'DOCKER_HOST' ) as Object
-    [ project.tasks.getByName( 'dockerClean' ),
-      project.tasks.getByName( 'dockerPrepare' ),
-      project.tasks.getByName( 'docker' )
-    ].each { Task dockerTask ->
-      dockerTask.inputs.property 'dockerHostEnv', dockerHost
-      dockerTask.onlyIf { dockerHost }
+    project.plugins.apply DependenciesPlugin
+    applyDockerPlugin( project )
+    applyDockerBuildImage( project )
+  }
+
+  private void applyDockerPlugin( Project project )
+  {
+    project.plugins.apply DockerRemoteApiPlugin
+    def dockerExtension = project.extensions.getByType DockerExtension
+    dockerExtension.certPath = dockerCertPath ?
+                               new File( dockerCertPath ) :
+                               new File( System.getProperty( 'user.home' ), '.boot2docker/certs/boot2docker-vm'
)
+  }
+
+  private void applyDockerBuildImage( Project project )
+  {
+    def classesTask = project.tasks.getByName 'classes'
+    def dockers = project.file( 'src/main/docker' )
+    dockers.eachDir { File dockerDir ->
+      def dockerName = dockerDir.name
+      def taskName = "build${ dockerName.capitalize() }DockerImage"
+      project.tasks.create( taskName, DockerBuildImage ) { DockerBuildImage task ->
+        task.group = 'docker'
+        task.description = "Build $dockerName Docker image"
+        task.onlyIf { dockerHost }
+        task.inputs.property 'dockerMachineName', dockerMachineName
+        task.inputs.property 'dockerHostEnv', dockerHost
+        task.inputs.property 'dockerCertPath', dockerCertPath
+        task.inputDir = dockerDir
+        task.dockerFile = new File( dockerDir, 'Dockerfile' )
+        task.tag = "org.apache.polygene:${ PublishNaming.publishedNameFor ":internals:docker-$dockerName"
}"
+        // Ensure that all Docker images are built alongside this project
+        // This is a bit of a stretch but works for now
+        classesTask.dependsOn task
+      }
     }
-    project.tasks.getByName( LifecycleBasePlugin.BUILD_TASK_NAME ).dependsOn 'docker'
   }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-memcached/build.gradle
----------------------------------------------------------------------
diff --git a/internals/docker-memcached/build.gradle b/internals/docker-memcached/build.gradle
deleted file mode 100644
index d6f59e0..0000000
--- a/internals/docker-memcached/build.gradle
+++ /dev/null
@@ -1,19 +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.
- */
-
-apply plugin: 'polygene-internal-docker'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-memcached/src/main/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/docker-memcached/src/main/docker/Dockerfile b/internals/docker-memcached/src/main/docker/Dockerfile
deleted file mode 100644
index dd2ef40..0000000
--- a/internals/docker-memcached/src/main/docker/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-FROM memcached:alpine

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-mysql/build.gradle
----------------------------------------------------------------------
diff --git a/internals/docker-mysql/build.gradle b/internals/docker-mysql/build.gradle
deleted file mode 100644
index d6f59e0..0000000
--- a/internals/docker-mysql/build.gradle
+++ /dev/null
@@ -1,19 +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.
- */
-
-apply plugin: 'polygene-internal-docker'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-mysql/src/main/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/docker-mysql/src/main/docker/Dockerfile b/internals/docker-mysql/src/main/docker/Dockerfile
deleted file mode 100644
index f0169e9..0000000
--- a/internals/docker-mysql/src/main/docker/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-FROM mariadb:latest
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-postgres/build.gradle
----------------------------------------------------------------------
diff --git a/internals/docker-postgres/build.gradle b/internals/docker-postgres/build.gradle
deleted file mode 100644
index d6f59e0..0000000
--- a/internals/docker-postgres/build.gradle
+++ /dev/null
@@ -1,19 +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.
- */
-
-apply plugin: 'polygene-internal-docker'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-postgres/src/main/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/docker-postgres/src/main/docker/Dockerfile b/internals/docker-postgres/src/main/docker/Dockerfile
deleted file mode 100644
index e17d095..0000000
--- a/internals/docker-postgres/src/main/docker/Dockerfile
+++ /dev/null
@@ -1,2 +0,0 @@
-FROM postgres:alpine
-COPY init-test-db.sh /docker-entrypoint-initdb.d/init-test-db.sh

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-postgres/src/main/docker/init-test-db.sh
----------------------------------------------------------------------
diff --git a/internals/docker-postgres/src/main/docker/init-test-db.sh b/internals/docker-postgres/src/main/docker/init-test-db.sh
deleted file mode 100755
index 2c0c759..0000000
--- a/internals/docker-postgres/src/main/docker/init-test-db.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-set -e
-
-# Create test user and database
-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
-    CREATE USER jdbc_test_login;
-    CREATE DATABASE jdbc_test_db;
-    GRANT ALL PRIVILEGES ON DATABASE jdbc_test_db TO jdbc_test_login;
-EOSQL
-
-# Enable ltree extension on test database
-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d jdbc_test_db <<-EOSQL
-    CREATE EXTENSION ltree;
-EOSQL

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-redis/build.gradle
----------------------------------------------------------------------
diff --git a/internals/docker-redis/build.gradle b/internals/docker-redis/build.gradle
deleted file mode 100644
index d6f59e0..0000000
--- a/internals/docker-redis/build.gradle
+++ /dev/null
@@ -1,19 +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.
- */
-
-apply plugin: 'polygene-internal-docker'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/docker-redis/src/main/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/docker-redis/src/main/docker/Dockerfile b/internals/docker-redis/src/main/docker/Dockerfile
deleted file mode 100644
index 058f6b2..0000000
--- a/internals/docker-redis/src/main/docker/Dockerfile
+++ /dev/null
@@ -1 +0,0 @@
-FROM redis:alpine

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/testsupport-internal/build.gradle
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/build.gradle b/internals/testsupport-internal/build.gradle
index cd67ed9..f946b94 100644
--- a/internals/testsupport-internal/build.gradle
+++ b/internals/testsupport-internal/build.gradle
@@ -17,6 +17,7 @@
  */
 
 apply plugin: 'polygene-internal'
+apply plugin: 'polygene-internal-docker'
 
 dependencies {
   compile polygene.core.testsupport
@@ -24,10 +25,3 @@ dependencies {
 
   runtime polygene.core.runtime
 }
-
-// Ensure that all Docker images are built alongside this project
-// This is a bit of a stretch but works for now
-classes.dependsOn ':internals:docker-memcached:docker'
-classes.dependsOn ':internals:docker-mysql:docker'
-classes.dependsOn ':internals:docker-postgres:docker'
-classes.dependsOn ':internals:docker-redis:docker'

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/testsupport-internal/src/main/docker/memcached/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/memcached/Dockerfile b/internals/testsupport-internal/src/main/docker/memcached/Dockerfile
new file mode 100644
index 0000000..dd2ef40
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/memcached/Dockerfile
@@ -0,0 +1 @@
+FROM memcached:alpine

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/testsupport-internal/src/main/docker/mysql/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/mysql/Dockerfile b/internals/testsupport-internal/src/main/docker/mysql/Dockerfile
new file mode 100644
index 0000000..f0169e9
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/mysql/Dockerfile
@@ -0,0 +1 @@
+FROM mariadb:latest
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/testsupport-internal/src/main/docker/postgres/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/postgres/Dockerfile b/internals/testsupport-internal/src/main/docker/postgres/Dockerfile
new file mode 100644
index 0000000..e17d095
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/postgres/Dockerfile
@@ -0,0 +1,2 @@
+FROM postgres:alpine
+COPY init-test-db.sh /docker-entrypoint-initdb.d/init-test-db.sh

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/testsupport-internal/src/main/docker/postgres/init-test-db.sh
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/postgres/init-test-db.sh b/internals/testsupport-internal/src/main/docker/postgres/init-test-db.sh
new file mode 100755
index 0000000..2c0c759
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/postgres/init-test-db.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+
+# Create test user and database
+psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
+    CREATE USER jdbc_test_login;
+    CREATE DATABASE jdbc_test_db;
+    GRANT ALL PRIVILEGES ON DATABASE jdbc_test_db TO jdbc_test_login;
+EOSQL
+
+# Enable ltree extension on test database
+psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d jdbc_test_db <<-EOSQL
+    CREATE EXTENSION ltree;
+EOSQL

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/internals/testsupport-internal/src/main/docker/redis/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/redis/Dockerfile b/internals/testsupport-internal/src/main/docker/redis/Dockerfile
new file mode 100644
index 0000000..058f6b2
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/redis/Dockerfile
@@ -0,0 +1 @@
+FROM redis:alpine

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9b60364e/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index b03309f..6858c4c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -100,10 +100,6 @@ include 'core:api',
         'samples:sql-support',
         'samples:swing'
 
-include 'internals:testsupport-internal',
-        'internals:docker-memcached',
-        'internals:docker-mysql',
-        'internals:docker-postgres',
-        'internals:docker-redis'
+include 'internals:testsupport-internal'
 
 include 'manual', 'reports', 'distributions', 'release'


Mime
View raw message