Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds platform image's param #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/kotlin/com/revolut/jooq/Docker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any>,
private val portBinding: Pair<Int, Int>,
private val readinessCommand: Array<String>,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/com/revolut/jooq/GenerateJooqClassesTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ open class GenerateJooqClassesTask : DefaultTask() {
@Input
fun getImageRepository() = getImage().repository

@Input
fun getPlatform() = getImage().platform

@Input
fun getImageTag() = getImage().tag

Expand Down Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/revolut/jooq/JooqExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ open class JooqExtension(projectName: String) : Serializable {
var tag = "14.5-alpine"
var envVars: Map<String, Any> = 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;")
Expand Down
1 change: 1 addition & 0 deletions src/test/groovy/JooqDockerPluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down