Skip to content

Commit

Permalink
feat!: upgrade bmuschko docker plugin (#93001)
Browse files Browse the repository at this point in the history
* gradle tasks to start a container have been split into the 3 different aspects:
  1. *find* the container by name
  2. if not existing: *create*
  3. if not running: *start*
  • Loading branch information
skiesewetter-intershop committed Feb 6, 2024
1 parent f42224d commit 087d869
Show file tree
Hide file tree
Showing 48 changed files with 1,536 additions and 1,446 deletions.
48 changes: 17 additions & 31 deletions README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= Intershop Commerce Management - Docker Plugins
:latestRevision: 4.1.0
:latestRevision: 5.0.0
:gradlePluginVersion: 6.0.0
:toc:
:icons: font

Expand Down Expand Up @@ -27,7 +28,7 @@ The plugins must be applied to the root project.
[subs=+attributes]
----
plugins {
id 'com.intershop.gradle.icm.base' version '3.4.14'
id 'com.intershop.gradle.icm.base' version '{gradlePluginVersion}'
id 'com.intershop.gradle.icm.docker' version '{latestRevision}'
}
Expand All @@ -39,11 +40,10 @@ intershop {
intershop_docker {
images {
webadapter = 'intershophub/icm-webadapter:2.1.0'
webadapteragent = 'intershophub/icm-webadapteragent:3.1.0'
webadapter = 'intershophub/icm-webadapter:2.4.9'
webadapteragent = 'intershophub/icm-webadapteragent:4.0.0'
mssql = 'intershophub/mssql-intershop:2019-latest'
oracle = 'intershophub/oracle-intershop:latest'
mailsrv = 'mailhog/mailhog:latest'
}
Expand Down Expand Up @@ -86,7 +86,7 @@ intershop_docker {
[subs=+attributes]
----
plugins {
id("com.intershop.gradle.icm.base") version "3.4.14"
id("com.intershop.gradle.icm.base") version "{gradlePluginVersion}"
id("com.intershop.gradle.icm.docker") version "{latestRevision}"
}
Expand All @@ -98,11 +98,10 @@ intershop {
intershop_docker {
images {
webadapter.set("'intershophub/icm-webadapter:2.1.0")
webadapteragent.set("intershophub/icm-webadapteragent:3.1.0")
webadapter.set("'intershophub/icm-webadapter:2.4.9")
webadapteragent.set("intershophub/icm-webadapteragent:4.0.0")
mssql.set("intershophub/mssql-intershop:2019-latest")
oracle.set("intershophub/oracle-intershop:latest")
mailsrv.set("mailhog/mailhog:latest")
}
Expand Down Expand Up @@ -210,7 +209,6 @@ imageBuild {
|`webadapter` | `Property<String>` | `docker.intershop.de/intershop/icm-webadapter:latest` | The image contains the web server of the Intershop Commerce Management application with a special Intershop Apache module.
|`webadapteragent` | `Property<String>` | `docker.intershop.de/intershop/icm-webadapteragent:latest` | The web adapter agent image of the Intershop Commerce Management application.
|`mssqldb` | `Property<String>` | `mcr.microsoft.com/mssql/server:2019-latest` | The Microsoft SQL server image. There will be also a build file available.
|`oracledb` | `Property<String>` | `docker.intershop.de/intershop/oracle-xe-server:18.4.0` | This image is only available internally. The build files will be provided.
|`mailsrv` | `Property<String>` | `mailhog/mailhog:latest` | A mail server for testing the mail feature of the application.
|`solr` | `Property<String>` | `solr/latest` | This image is used for the Solr Cloud configuration with a single node.
|`zookeeper` | `Property<String>` | `zookeeper:latest` | This image is used for the Solr Cloud configuration with a single node.
Expand Down Expand Up @@ -278,7 +276,6 @@ For all properties configurations methods with a closure or an action are availa
| *prepareNetwork* | Creates a network with the specified name <extension name>-network. All start tasks are dependend on this task.
| *removeNetwork* | Removes the network from the Docker configuration.
| **MSSQL* | These tasks pull, start, stop and remove the MSSQL image.
| **Oracle* | These tasks pull, start, stop and remove the Oracle DB image.
| **MailSrv* | These tasks pull, start, stop and remove the Mail server image.
| **SolrCloud* | These tasks orchestrate all Solr Cloud related tasks.
| **ZK* | These tasks pull, start, stop and remove the Zookeeper image.
Expand Down Expand Up @@ -306,8 +303,6 @@ The task can be called with the following parameters:
| Parameter |Description

| --db | Option for the used database. The following values are possible: +
_oracle-container_ - Oracle configuration for database provided by a container +
_oracle_ - Oracle configuration for an external database +
_mssql-container_ - MSSQL configuration for database provided by a container +
_mssql_ - MSSQL configuration for an external database
| --icmas | If this parameter specified, the properties file will be generated for app server development.
Expand Down Expand Up @@ -352,17 +347,6 @@ The following properties are part of the <<PropertiesFile>>.
| `intershop.jdbc.password` | the password of the actual DB user to be created | String | Optional | `intershop` +
|===

===== Oracle [[OracleConfiguration]]

[cols="10%,60%,10%,10%,10%", width="99%, options="header"]
|===
| Key | Description | Co-domain | Mandatory/Optional | Default value

| `intershop.db.oracle.listenerport` | Exposed listener port of the database. | Integer | Optional | `1521` +
| `intershop.db.oracle.port` | Exposed enterprise manager port of the oracle db. | Integer | Optional | `1521` +
| `intershop.db.oracle.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== WA [[WAConfiguration]]

[cols="10%,60%,10%,10%,10%", width="99%, options="header"]
Expand Down Expand Up @@ -503,7 +487,7 @@ The plugins must be applied to the root project.
|===
| Task name |Description

| **Container* | These tasks pull, start, stop and remove the ICM application server image with a special command. There is no running process inside, but it uses the same configuration like the appserver container.
| **Container* | These tasks pull, start, stop and remove the ICM application server image with a special command. There is no running process inside, but it uses the same configuration as the appserver container.
| **AS* | These tasks pull, start, stop and remove the ICM application server image.
| **Server* | These tasks orchestrate all ICM server related tasks (web server and app server)
| *dbPrepare* | This task starts dbPrepare inside the running "Container" docker container.
Expand Down Expand Up @@ -531,7 +515,7 @@ The following properties are part of the <<PropertiesFile>>.
| `intershop.servletEngine.managementConnector.port` | the host port to be used for the appserver management connector http port | Integer | Optional | `7743` +
| `intershop.as.jmx.connector.port` | the host port to be used for the appserver JMX port | Integer | Optional | `7747` +
| `intershop.as.debug.port` | the host port to be used for the appserver debug port | Integer | Optional | `7746` +
| `intershop.databaseType` | database type to be used | { `mssql`, `oracle` } | Mandatory | <none> +
| `intershop.databaseType` | database type to be used | { `mssql` } | Mandatory | <none> +
| `intershop.jdbc.url` | JDBC URL pointing to the database to be used | URL | Mandatory | <none> +
| `intershop.jdbc.user` | JDBC database user | String | Mandatory | <none> +
| `intershop.jdbc.password` | JDBC database password | String | Mandatory | <none> +
Expand All @@ -540,7 +524,8 @@ The following properties are part of the <<PropertiesFile>>.
|===

--
The referenced database can either be an externally running database or an instance started using the gradle <<DockerPluginTasks>> `startMSSQL` respectively `startOracle`. In either case the properties `intershop.databaseType` and `intershop.jdbc.*` have to be defined properly (when using the gradle tasks the hostname equals the container name).
The referenced database can either be an externally running database or an instance started using the gradle <<DockerPluginTasks>> `startMSSQL`.
In either case the properties `intershop.databaseType` and `intershop.jdbc.*` have to be defined properly (when using the gradle tasks the hostname equals the container name).
--

===== Application Server [[StartASConfiguration]]
Expand Down Expand Up @@ -601,6 +586,9 @@ NOTE: To make the `classpathLayout` `sourceJar` work the gradle-property `localV

===== Application Server [[StartASParameters]]

IMPORTANT: The following parameters actually belong to the task `createAS` (not `startAS`).
But if you just call for example `./gradlew startAS --debug-icm=suspend` the parameter(s) are also applied to the `createAS`-task (task `startAS` depends on `createAS`).

[cols="10%,70%,10%,10%", width="99%, options="header"]
|===
| Parameter | Description | Co-domain | Default value
Expand Down Expand Up @@ -975,8 +963,6 @@ The plugin set the following system properties for the test:
| `geb.build.baseUrl` | The url will be calculated from the base configuration of the web server image. If the container framework is used, the internal network name is used.
|===

Furthermore the host

==== Extension 'gebConfiguration'

*Properties*
Expand Down Expand Up @@ -1086,8 +1072,8 @@ icm.properties
[subs=+attributes]
----
# database connection configuration
intershop.databaseType = oracle|mssql
intershop.jdbc.url = jdbc:oracle:thin:@host:1521:XE | jdbc:sqlserver://host:1433;databaseName=dbname
intershop.databaseType = mssql
intershop.jdbc.url = jdbc:sqlserver://host:1433;databaseName=dbname
intershop.jdbc.user = user
intershop.jdbc.password = password
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ dependencies {
implementation(gradleKotlinDsl())

implementation("org.apache.solr:solr-solrj:9.4.0")
implementation("com.bmuschko:gradle-docker-plugin:8.1.0")
implementation("com.intershop.gradle.icm:icm-gradle-plugin:6.0.0")
implementation("com.bmuschko.docker-remote-api:com.bmuschko.docker-remote-api.gradle.plugin:9.3.6")
implementation("com.intershop.gradle.icm:icm-gradle-plugin:6.0.1")
implementation("com.intershop.gradle.jobrunner:icmjobrunner:1.0.5")
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.intershop.gradle.icm.docker.utils.CustomizationImageBuildPreparer
import com.intershop.gradle.icm.docker.utils.ISHUnitTestRegistry
import com.intershop.gradle.icm.docker.utils.appsrv.AbstractASTaskPreparer
import com.intershop.gradle.icm.docker.utils.network.TaskPreparer
import com.intershop.gradle.icm.docker.utils.appsrv.TaskPreparer as AppSrvPreparer
import com.intershop.gradle.icm.docker.utils.webserver.WATaskPreparer
import com.intershop.gradle.icm.extension.IntershopExtension
import org.gradle.api.GradleException
Expand All @@ -38,6 +37,7 @@ import org.gradle.api.UnknownTaskException
import org.gradle.api.artifacts.DependencySet
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.getByType
import com.intershop.gradle.icm.docker.utils.appsrv.TaskPreparer as AppSrvPreparer

/**
* Main plugin class of the customization plugin.
Expand Down Expand Up @@ -91,11 +91,9 @@ open class ICMDockerCustomizationPlugin : Plugin<Project> {
val icmExtension = project.extensions.getByType<IntershopExtension>()

val mssqlDatabase = tasks.named(
"start${com.intershop.gradle.icm.docker.utils.mssql.TaskPreparer.extName}")
val oracleDatabase = tasks.named(
"start${com.intershop.gradle.icm.docker.utils.oracle.TaskPreparer.extName}")
"start${com.intershop.gradle.icm.docker.utils.mssql.TaskPreparer.EXT_NAME}")
val mailSrvTask = tasks.named(
"start${com.intershop.gradle.icm.docker.utils.mail.TaskPreparer.extName}",
"start${com.intershop.gradle.icm.docker.utils.mail.TaskPreparer.EXT_NAME}",
StartExtraContainer::class.java)
val startSolrCloud = tasks.named(
"start${com.intershop.gradle.icm.docker.utils.solrcloud.TaskPreparer.TASK_EXT_SERVER}")
Expand Down Expand Up @@ -158,10 +156,10 @@ open class ICMDockerCustomizationPlugin : Plugin<Project> {
}

val dbPrepare: TaskProvider<DBPrepareTask> = getDBPrepare(this,
containerPreparer, mssqlDatabase, oracleDatabase)
containerPreparer, mssqlDatabase)

configureISHUnitTest(this,
dockerExtension, containerPreparer, dbPrepare, mssqlDatabase, oracleDatabase)
dockerExtension, containerPreparer, dbPrepare, mssqlDatabase)

addTestReportConfiguration(this)

Expand All @@ -181,7 +179,7 @@ open class ICMDockerCustomizationPlugin : Plugin<Project> {
}

/**
* Determines the name of the customization that is associated the project this plugin is applied to.
* Determines the name of the customization that is associated to the project this plugin is applied to.
*
* __Attention__: extends the class [Project] by this function
*/
Expand All @@ -191,15 +189,14 @@ open class ICMDockerCustomizationPlugin : Plugin<Project> {
project: Project,
containerPreparer: AbstractASTaskPreparer,
mssqlDatabase: TaskProvider<Task>,
oracleDatabase: TaskProvider<Task>,
): TaskProvider<DBPrepareTask> {
return project.tasks.register(DBPrepareTask.TASK_NAME, DBPrepareTask::class.java) { task ->
task.group = ICMDockerPlugin.GROUP_SERVERBUILD
task.description = "Starts dbPrepare in an existing ICM base container."
task.executeUsing(containerPreparer.startTask)

task.finalizedBy(containerPreparer.removeTask)
task.mustRunAfter(mssqlDatabase, oracleDatabase)
task.mustRunAfter(mssqlDatabase)
}
}

Expand All @@ -209,7 +206,7 @@ open class ICMDockerCustomizationPlugin : Plugin<Project> {
containerPreparer: AbstractASTaskPreparer,
dbPrepare: TaskProvider<DBPrepareTask>,
mssqlDatabase: TaskProvider<Task>,
oracleDatabase: TaskProvider<Task>) {
) {
project.gradle.sharedServices.registerIfAbsent(ISHUNIT_REGISTRY,
ISHUnitTestRegistry::class.java) {
it.maxParallelUsages.set(1)
Expand All @@ -232,7 +229,7 @@ open class ICMDockerCustomizationPlugin : Plugin<Project> {
task.testSuite.set(suite.testSuite)

task.finalizedBy(containerPreparer.removeTask)
task.mustRunAfter(dbPrepare, mssqlDatabase, oracleDatabase)
task.mustRunAfter(dbPrepare, mssqlDatabase)
}

ishUnitTest.configure { task ->
Expand Down
27 changes: 8 additions & 19 deletions src/main/kotlin/com/intershop/gradle/icm/docker/ICMDockerPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import com.intershop.gradle.icm.docker.utils.mssql.TaskPreparer as MSSQLPreparer
import com.intershop.gradle.icm.docker.utils.mssql.TaskPreparer as MSSQLTaskPreparer
import com.intershop.gradle.icm.docker.utils.network.TaskPreparer as NetworkPreparer
import com.intershop.gradle.icm.docker.utils.nginx.TaskPreparer as NginxTaskPreparer
import com.intershop.gradle.icm.docker.utils.oracle.TaskPreparer as OraclePreparer
import com.intershop.gradle.icm.docker.utils.oracle.TaskPreparer as OracleTaskPreparer
import com.intershop.gradle.icm.docker.utils.redis.TaskPreparer as RedisTaskPreparer
import com.intershop.gradle.icm.docker.utils.solrcloud.TaskPreparer as SolrCloudPreparer
import com.intershop.gradle.icm.docker.utils.solrcloud.TaskPreparer as SolrTaskPreparer
Expand Down Expand Up @@ -80,7 +78,6 @@ open class ICMDockerPlugin : Plugin<Project> {
val networkTasks = NetworkPreparer(project, extension)

val mssqlTasks = MSSQLPreparer(project, networkTasks.createNetworkTask)
val oracleTasks = OraclePreparer(project, networkTasks.createNetworkTask)
val mailSrvTask = MailSrvPreparer(project, networkTasks.createNetworkTask)
val solrcloudPreparer = SolrCloudPreparer(project, networkTasks)

Expand All @@ -91,7 +88,6 @@ open class ICMDockerPlugin : Plugin<Project> {
try {
tasks.named("dbPrepare").configure {
it.mustRunAfter(mssqlTasks.startTask)
it.mustRunAfter(oracleTasks.startTask)
}
} catch (ex: UnknownTaskException) {
project.logger.info("No dbPrepare task available!")
Expand All @@ -106,7 +102,6 @@ open class ICMDockerPlugin : Plugin<Project> {
mailSrvTask.removeTask,
webServerTasks.removeTask,
nginxTasks.removeTask,
oracleTasks.removeTask,
solrcloudPreparer.removeTask,
redisTasks.removeTask)
}
Expand Down Expand Up @@ -143,7 +138,7 @@ open class ICMDockerPlugin : Plugin<Project> {
task.group = GROUP_CONTAINER
task.description = "Start all container from Docker for the selected environment"
if (list.contains("mail")) {
task.dependsOn("start${MailTaskPreparer.extName}")
task.dependsOn("start${MailTaskPreparer.EXT_NAME}")
}
if (list.contains("webserver")) {
task.dependsOn("start${WebTaskPreparer.TASK_EXT_SERVER}")
Expand All @@ -152,24 +147,21 @@ open class ICMDockerPlugin : Plugin<Project> {
task.dependsOn("start${SolrTaskPreparer.TASK_EXT_SERVER}")
}
if (list.contains("mssql")) {
task.dependsOn("start${MSSQLTaskPreparer.extName}")
}
if (list.contains("oracle")) {
task.dependsOn("start${OracleTaskPreparer.extName}")
task.dependsOn("start${MSSQLTaskPreparer.EXT_NAME}")
}
if (list.contains("nginx")) {
task.dependsOn("start${NginxTaskPreparer.extName}")
task.dependsOn("start${NginxTaskPreparer.EXT_NAME}")
}
if (list.contains("redis")) {
task.dependsOn("start${RedisTaskPreparer.extName}")
task.dependsOn("start${RedisTaskPreparer.EXT_NAME}")
}
}

project.tasks.register("stopEnv") { task ->
task.group = GROUP_CONTAINER
task.description = "Stops all container from Docker for the selected environment"
if (list.contains("mail")) {
task.dependsOn("stop${MailTaskPreparer.extName}")
task.dependsOn("stop${MailTaskPreparer.EXT_NAME}")
}
if (list.contains("webserver")) {
task.dependsOn("stop${WebTaskPreparer.TASK_EXT_SERVER}")
Expand All @@ -178,16 +170,13 @@ open class ICMDockerPlugin : Plugin<Project> {
task.dependsOn("stop${SolrTaskPreparer.TASK_EXT_SERVER}")
}
if (list.contains("mssql")) {
task.dependsOn("stop${MSSQLTaskPreparer.extName}")
}
if (list.contains("oracle")) {
task.dependsOn("stop${OracleTaskPreparer.extName}")
task.dependsOn("stop${MSSQLTaskPreparer.EXT_NAME}")
}
if (list.contains("nginx")) {
task.dependsOn("stop${NginxTaskPreparer.extName}")
task.dependsOn("stop${NginxTaskPreparer.EXT_NAME}")
}
if (list.contains("redis")) {
task.dependsOn("stop${RedisTaskPreparer.extName}")
task.dependsOn("stop${RedisTaskPreparer.EXT_NAME}")
}
}
}
Expand Down
Loading

0 comments on commit 087d869

Please sign in to comment.