Skip to content

Commit 175f4be

Browse files
Merge pull request #4 from adRise/huajiang/chore/add-setting-key-for-postgres-image-name
add a setting key for postgres image name
2 parents afdb32f + 15bfa46 commit 175f4be

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/scala/com/github/tototoshi/sbt/slick/PluginDBSupport.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait PluginDBSupport {
1515
protected val startDb = taskKey[Unit]("Stop and remove the postgres container")
1616

1717
lazy val postgresContainerPort = settingKey[Int]("The port of postgres port")
18+
lazy val postgresImage = settingKey[String]("The postgres image name")
1819
lazy val postgresVersion = settingKey[String]("The postgres version")
1920

2021
protected def dbSettings: Seq[sbt.Setting[_]] = {
@@ -24,6 +25,7 @@ trait PluginDBSupport {
2425
flywayDefaults / Keys.logLevel := Level.Warn,
2526
postgresDbUrl := s"jdbc:postgresql://127.0.0.1:${postgresContainerPort.value}/postgres",
2627
postgresContainerPort := 15432,
28+
postgresImage := "postgres",
2729
postgresVersion := "13.7",
2830
flywayUrl := postgresDbUrl.value,
2931
flywayUser := dbUser,
@@ -35,6 +37,7 @@ trait PluginDBSupport {
3537
PostgresContainer.start(
3638
exportPort = postgresContainerPort.value,
3739
password = dbPass,
40+
postgresImage = postgresImage.value,
3841
postgresVersion = postgresVersion.value,
3942
logger = Keys.streams.value.log
4043
)

src/main/scala/com/tubitv/PostgresContainer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ object PostgresContainer {
1818

1919
private val runningDb = new AtomicReference[Option[String]](None)
2020

21-
def start(exportPort: Int, password: String, postgresVersion: String, logger: Logger): Unit = {
21+
def start(exportPort: Int, password: String, postgresImage: String, postgresVersion: String, logger: Logger): Unit = {
2222
runningDb.get() match {
2323
case None =>
24-
val image = s"postgres:$postgresVersion"
24+
val image = s"$postgresImage:$postgresVersion"
2525
val dockerClient = DockerClientBuilder.getInstance.build
2626
Try(dockerClient.inspectImageCmd(image).exec()).recover {
2727
case _: NotFoundException =>

0 commit comments

Comments
 (0)