diff --git a/src/main/scala/com/github/tototoshi/sbt/slick/PluginDBSupport.scala b/src/main/scala/com/github/tototoshi/sbt/slick/PluginDBSupport.scala index 24db30f..407b184 100644 --- a/src/main/scala/com/github/tototoshi/sbt/slick/PluginDBSupport.scala +++ b/src/main/scala/com/github/tototoshi/sbt/slick/PluginDBSupport.scala @@ -15,6 +15,7 @@ trait PluginDBSupport { protected val startDb = taskKey[Unit]("Stop and remove the postgres container") lazy val postgresContainerPort = settingKey[Int]("The port of postgres port") + lazy val postgresImage = settingKey[String]("The postgres image name") lazy val postgresVersion = settingKey[String]("The postgres version") protected def dbSettings: Seq[sbt.Setting[_]] = { @@ -24,6 +25,7 @@ trait PluginDBSupport { flywayDefaults / Keys.logLevel := Level.Warn, postgresDbUrl := s"jdbc:postgresql://127.0.0.1:${postgresContainerPort.value}/postgres", postgresContainerPort := 15432, + postgresImage := "postgres", postgresVersion := "13.7", flywayUrl := postgresDbUrl.value, flywayUser := dbUser, @@ -35,6 +37,7 @@ trait PluginDBSupport { PostgresContainer.start( exportPort = postgresContainerPort.value, password = dbPass, + postgresImage = postgresImage.value, postgresVersion = postgresVersion.value, logger = Keys.streams.value.log ) diff --git a/src/main/scala/com/tubitv/PostgresContainer.scala b/src/main/scala/com/tubitv/PostgresContainer.scala index 397336a..b5c747a 100644 --- a/src/main/scala/com/tubitv/PostgresContainer.scala +++ b/src/main/scala/com/tubitv/PostgresContainer.scala @@ -18,10 +18,10 @@ object PostgresContainer { private val runningDb = new AtomicReference[Option[String]](None) - def start(exportPort: Int, password: String, postgresVersion: String, logger: Logger): Unit = { + def start(exportPort: Int, password: String, postgresImage: String, postgresVersion: String, logger: Logger): Unit = { runningDb.get() match { case None => - val image = s"postgres:$postgresVersion" + val image = s"$postgresImage:$postgresVersion" val dockerClient = DockerClientBuilder.getInstance.build Try(dockerClient.inspectImageCmd(image).exec()).recover { case _: NotFoundException =>