polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [22/50] [abbrv] polygene-java git commit: build: move Docker image dependencies declaration in ~/dependencies.gradle
Date Sun, 26 Feb 2017 22:47:44 GMT
build: move Docker image dependencies declaration in ~/dependencies.gradle

And use fixed image versions instead of dynamic versions


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

Branch: refs/heads/serialization-3.0
Commit: cdd2719d291050fb1a319b122bb786412d6aa415
Parents: 7cedbf2
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sat Feb 25 17:34:08 2017 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sat Feb 25 17:34:08 2017 +0100

----------------------------------------------------------------------
 .../DependenciesDeclarationExtension.groovy     |  1 +
 .../internals/InternalDockerPlugin.groovy       | 63 +++++++++++++++-----
 dependencies.gradle                             | 11 ++++
 .../src/main/docker/cassandra/Dockerfile        |  2 +-
 .../src/main/docker/memcached/Dockerfile        |  2 +-
 .../src/main/docker/mysql/Dockerfile            |  2 +-
 .../src/main/docker/postgres/Dockerfile         |  2 +-
 .../src/main/docker/redis/Dockerfile            |  2 +-
 .../src/main/docker/riak/Dockerfile             |  2 +-
 9 files changed, 65 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/buildSrc/src/main/groovy/org/apache/polygene/gradle/dependencies/DependenciesDeclarationExtension.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/dependencies/DependenciesDeclarationExtension.groovy
b/buildSrc/src/main/groovy/org/apache/polygene/gradle/dependencies/DependenciesDeclarationExtension.groovy
index b9dc1e0..afd1ede 100644
--- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/dependencies/DependenciesDeclarationExtension.groovy
+++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/dependencies/DependenciesDeclarationExtension.groovy
@@ -30,4 +30,5 @@ class DependenciesDeclarationExtension
   final Map<String, List<Object>> defaultDependencies = [ : ]
   BiConsumer<DependencySubstitution, ModuleComponentSelector> dependencySubstitutionSpec
   final Map<String, String> buildToolsVersions = [ : ]
+  final Map<String, String> dockerImagesVersions = [ : ]
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/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 cdfd95d..2247caf 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
@@ -25,15 +25,24 @@ import groovy.transform.CompileStatic
 import org.apache.polygene.gradle.BasePlugin
 import org.apache.polygene.gradle.code.CodePlugin
 import org.apache.polygene.gradle.code.PublishNaming
+import org.apache.polygene.gradle.dependencies.DependenciesDeclarationExtension
 import org.apache.polygene.gradle.dependencies.DependenciesPlugin
+import org.apache.tools.ant.filters.ReplaceTokens
 import org.gradle.api.Action
 import org.gradle.api.Plugin
 import org.gradle.api.Project
+import org.gradle.api.Task
+import org.gradle.api.file.CopySpec
 import org.gradle.api.logging.LogLevel
 
 @CompileStatic
 class InternalDockerPlugin implements Plugin<Project>
 {
+  static class TaskNames
+  {
+    static final String CHECK_DOCKER_CONNECTIVITY = 'checkDockerConnectivity'
+  }
+
   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' )
@@ -61,7 +70,7 @@ class InternalDockerPlugin implements Plugin<Project>
 
   private void applyDockerSwitch( Project project )
   {
-    project.tasks.create( 'checkDockerConnectivity', DockerVersion, { DockerVersion task
->
+    project.tasks.create( TaskNames.CHECK_DOCKER_CONNECTIVITY, DockerVersion, { DockerVersion
task ->
       task.onError = { ex ->
         // Disable Docker for this build
         project.rootProject.extensions.extraProperties.set( CodePlugin.DOCKER_DISABLED_EXTRA_PROPERTY,
true )
@@ -81,28 +90,50 @@ class InternalDockerPlugin implements Plugin<Project>
   {
     def classesTask = project.tasks.getByName 'classes'
     def dockers = project.file( 'src/main/docker' )
+    def dependencies = project.rootProject.extensions.getByType( DependenciesDeclarationExtension
)
     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.dependsOn 'checkDockerConnectivity'
-        task.onlyIf {
-          def extra = project.rootProject.extensions.extraProperties
-          !( extra.has( CodePlugin.DOCKER_DISABLED_EXTRA_PROPERTY ) &&
-             extra.get( CodePlugin.DOCKER_DISABLED_EXTRA_PROPERTY ) )
+      def buildDockerfileTaskName = "build${ dockerName.capitalize() }Dockerfile"
+      def buildImageTaskName = "build${ dockerName.capitalize() }DockerImage"
+      def tmpDir = project.file "${ project.buildDir }/tmp/docker/${ dockerName }"
+      tmpDir.mkdirs()
+      def buildDockerfileTask = project.tasks.create( buildDockerfileTaskName ) { Task task
->
+        task.description = "Build $dockerName Dockerfile"
+        task.inputs.property 'dockerImagesVersions', dependencies.dockerImagesVersions
+        task.inputs.dir dockerDir
+        task.outputs.dir tmpDir
+        // Filter Dockerfile for image versions from dependencies declaration
+        task.doFirst {
+          project.copy { CopySpec spec ->
+            spec.from( dockerDir ) { CopySpec unfiltered ->
+              unfiltered.exclude 'Dockerfile'
+            }
+            spec.from( dockerDir ) { CopySpec filtered ->
+              filtered.include 'Dockerfile'
+              filtered.filter ReplaceTokens, tokens: dependencies.dockerImagesVersions
+            }
+            spec.into tmpDir
+          }
         }
+      }
+      def buildImageTask = project.tasks.create( buildImageTaskName, DockerBuildImage, {
DockerBuildImage task ->
+        task.description = "Build $dockerName Docker image"
+        task.inputDir = tmpDir
+        task.dockerFile = new File( tmpDir, 'Dockerfile' )
+        task.tag = "org.apache.polygene:${ PublishNaming.publishedNameFor ":internals:docker-$dockerName"
}"
+      } as Action<DockerBuildImage> )
+      [ buildDockerfileTask, buildImageTask ].each { Task task ->
+        task.group = 'docker'
+        task.dependsOn TaskNames.CHECK_DOCKER_CONNECTIVITY
+        task.onlyIf { !project.rootProject.findProperty( CodePlugin.DOCKER_DISABLED_EXTRA_PROPERTY
) }
         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
       }
+      buildImageTask.dependsOn buildDockerfileTask
+      // Ensure that all Docker images are built alongside this project
+      // This is a bit of a stretch but works for now
+      classesTask.dependsOn buildImageTask
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/dependencies.gradle
----------------------------------------------------------------------
diff --git a/dependencies.gradle b/dependencies.gradle
index c8605a4..932bf85 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -251,3 +251,14 @@ dependencies.dependencySubstitutionSpec = { DependencySubstitution substitution,
 dependencies.buildToolsVersions << [
   jacoco: '0.7.8'
 ]
+
+// Docker Images
+dependencies.dockerImagesVersions << [
+  cassandra: 'cassandra:3.10',
+  fakeS3: 'lphoward/fake-s3:14.04',
+  memcached: 'memcached:1.4-alpine',
+  mariadb: 'mariadb:10.1',
+  postgres: 'postgres:9.6-alpine',
+  redis: 'redis:3.2-alpine',
+  riak: 'basho/riak-kv:ubuntu-2.2.0'
+]

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/internals/testsupport-internal/src/main/docker/cassandra/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/cassandra/Dockerfile b/internals/testsupport-internal/src/main/docker/cassandra/Dockerfile
index e382cc1..11d22b4 100644
--- a/internals/testsupport-internal/src/main/docker/cassandra/Dockerfile
+++ b/internals/testsupport-internal/src/main/docker/cassandra/Dockerfile
@@ -13,4 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM cassandra:3.9
+FROM @cassandra@

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/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
index d9e7020..0b1a4b2 100644
--- a/internals/testsupport-internal/src/main/docker/memcached/Dockerfile
+++ b/internals/testsupport-internal/src/main/docker/memcached/Dockerfile
@@ -13,4 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM memcached:alpine
+FROM @memcached@

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/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
index 4e5c49c..967d45d 100644
--- a/internals/testsupport-internal/src/main/docker/mysql/Dockerfile
+++ b/internals/testsupport-internal/src/main/docker/mysql/Dockerfile
@@ -13,4 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM mariadb:latest
\ No newline at end of file
+FROM @mariadb@
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/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
index 90bcffe..d3dad53 100644
--- a/internals/testsupport-internal/src/main/docker/postgres/Dockerfile
+++ b/internals/testsupport-internal/src/main/docker/postgres/Dockerfile
@@ -13,5 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM postgres:alpine
+FROM @postgres@
 COPY init-test-db.sh /docker-entrypoint-initdb.d/init-test-db.sh

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/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
index 74a7806..d0e67fc 100644
--- a/internals/testsupport-internal/src/main/docker/redis/Dockerfile
+++ b/internals/testsupport-internal/src/main/docker/redis/Dockerfile
@@ -13,4 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM redis:alpine
+FROM @redis@

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/cdd2719d/internals/testsupport-internal/src/main/docker/riak/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/riak/Dockerfile b/internals/testsupport-internal/src/main/docker/riak/Dockerfile
index e02ba9b..776d7af 100644
--- a/internals/testsupport-internal/src/main/docker/riak/Dockerfile
+++ b/internals/testsupport-internal/src/main/docker/riak/Dockerfile
@@ -13,4 +13,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM basho/riak-kv:latest
+FROM @riak@


Mime
View raw message