From 9c3bca093da30ff9245fc3b3ab1aee36df60701b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20El=C3=ADzaga?= Date: Fri, 17 Nov 2023 11:11:29 +0100 Subject: [PATCH] Adds platform image's param --- src/main/kotlin/com/revolut/jooq/Docker.kt | 2 ++ src/main/kotlin/com/revolut/jooq/GenerateJooqClassesTask.kt | 4 ++++ src/main/kotlin/com/revolut/jooq/JooqExtension.kt | 1 + src/test/groovy/JooqDockerPluginSpec.groovy | 1 + 4 files changed, 8 insertions(+) diff --git a/src/main/kotlin/com/revolut/jooq/Docker.kt b/src/main/kotlin/com/revolut/jooq/Docker.kt index 1a58fcd..ae8b7e9 100644 --- a/src/main/kotlin/com/revolut/jooq/Docker.kt +++ b/src/main/kotlin/com/revolut/jooq/Docker.kt @@ -20,6 +20,7 @@ import java.time.Duration import java.util.UUID.randomUUID class Docker(private val imageName: String, + private val platform: String, private val env: Map, private val portBinding: Pair, private val readinessCommand: Array, @@ -58,6 +59,7 @@ class Docker(private val imageName: String, private fun startContainer() { val dbPort = ExposedPort.tcp(portBinding.first) docker.createContainerCmd(imageName) + .withPlatform(platform) .withName(containerName) .withEnv(env.map { "${it.key}=${it.value}" }) .withExposedPorts(dbPort) diff --git a/src/main/kotlin/com/revolut/jooq/GenerateJooqClassesTask.kt b/src/main/kotlin/com/revolut/jooq/GenerateJooqClassesTask.kt index 536168a..4781e79 100644 --- a/src/main/kotlin/com/revolut/jooq/GenerateJooqClassesTask.kt +++ b/src/main/kotlin/com/revolut/jooq/GenerateJooqClassesTask.kt @@ -87,6 +87,9 @@ open class GenerateJooqClassesTask : DefaultTask() { @Input fun getImageRepository() = getImage().repository + @Input + fun getPlatform() = getImage().platform + @Input fun getImageTag() = getImage().tag @@ -143,6 +146,7 @@ open class GenerateJooqClassesTask : DefaultTask() { val jdbcAwareClassLoader = buildJdbcArtifactsAwareClassLoader() val docker = Docker( image.getImageName(), + image.platform, image.envVars, db.port to db.exposedPort, image.getReadinessCommand(), diff --git a/src/main/kotlin/com/revolut/jooq/JooqExtension.kt b/src/main/kotlin/com/revolut/jooq/JooqExtension.kt index e35f45b..0b891c8 100644 --- a/src/main/kotlin/com/revolut/jooq/JooqExtension.kt +++ b/src/main/kotlin/com/revolut/jooq/JooqExtension.kt @@ -52,6 +52,7 @@ open class JooqExtension(projectName: String) : Serializable { var tag = "14.5-alpine" var envVars: Map = mapOf("POSTGRES_USER" to db.username, "POSTGRES_PASSWORD" to db.password, "POSTGRES_DB" to db.name) var containerName = "jooq-docker-container-${projectName}" + var platform = "" var readinessProbeHost = "127.0.0.1" var readinessProbe = { host: String, port: Int -> arrayOf("sh", "-c", "until pg_isready -h $host -p $port; do echo waiting for db; sleep 1; done;") diff --git a/src/test/groovy/JooqDockerPluginSpec.groovy b/src/test/groovy/JooqDockerPluginSpec.groovy index cc01369..be3e47b 100644 --- a/src/test/groovy/JooqDockerPluginSpec.groovy +++ b/src/test/groovy/JooqDockerPluginSpec.groovy @@ -475,6 +475,7 @@ class JooqDockerPluginSpec extends Specification { image { repository = "mysql" tag = "8.0.15" + platform = "linux/x86_64" envVars = mapOf( "MYSQL_ROOT_PASSWORD" to "mysql", "MYSQL_DATABASE" to "mysql")