Add sbt dynver

This commit is contained in:
Rohan Sircar 2021-04-18 11:22:52 +05:30
parent 5d12bdd3ce
commit 2ff30c8615
3 changed files with 24 additions and 10 deletions

View File

@ -95,8 +95,6 @@ jobs:
with:
username: rohansircar
password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Migrate
run: csbt flyway/flywayMigrate
- name: Publish

View File

@ -27,13 +27,22 @@ lazy val databaseUrl =
lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user")
lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password")
// alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless"
lazy val dockerJavaImage =
sys.env.getOrElse("DOCKER_JAVA_IMAGE", "openjdk:11-jre-slim-buster")
lazy val releaseVersion = sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT")
lazy val dockerPublishTag = sys.env
.get("DOCKER_PUBLISH_TAG")
.orElse(sys.env.get("RELEASE_VERSION"))
.getOrElse("latest")
// lazy val releaseVersion = {
// val str = sys.env.get("RELEASE_VERSION")
// str.map(s => if (s.startsWith("v")) s.tail else s)
// }
// lazy val dockerPublishTag = {
// val s = sys.env
// .get("DOCKER_PUBLISH_TAG")
// .orElse(sys.env.get("RELEASE_VERSION"))
// .getOrElse("latest")
// if (s.startsWith("v")) s.tail else s
// }
lazy val flyway = (project in file("modules/flyway"))
.enablePlugins(FlywayPlugin)
@ -51,9 +60,14 @@ lazy val root = (project in file("."))
.settings(
organization := "wow.doge",
name := "http4s-demo",
version := releaseVersion,
version in Docker := dockerPublishTag,
// alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless"
// version := releaseVersion.getOrElse(dynver.value),
version in Docker := sys.env
.getOrElse(
"DOCKER_PUBLISH_TAG", {
val s = version.value
if (s.startsWith("v")) s.tail else s
}
),
dockerBaseImage := dockerJavaImage,
dockerExposedPorts := Seq(8081),
dockerUsername := Some("rohansircar"),

View File

@ -12,3 +12,5 @@ addSbtPlugin("com.github.tototoshi" % "sbt-slick-codegen" % "1.4.0")
addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "7.4.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.23")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")