diff --git a/Dockerfile b/Dockerfile index ba89e49..bfcc204 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ARG DOCKER_BUILD=yes RUN cd ./source \ && sbt assembly \ && cd .. \ -&& cp ./source/target/morny-coeur-docker-build.jar ./morny-coeur.jar +&& cp ./source/morny-coeur/target/morny-coeur-docker-build.jar ./morny-coeur.jar #&& rm -r ./source \ #&& rm -r /root/.gradle \ diff --git a/build.sbt b/build.sbt index 7786604..d1d35eb 100644 --- a/build.sbt +++ b/build.sbt @@ -13,7 +13,10 @@ ThisBuild / resolvers ++= Seq( ThisBuild / crossPaths := false -ThisBuild / Compile / packageDoc / publishArtifact := false +if (!MornyProject.publishWithDocJar) { + (ThisBuild / packageDoc / publishArtifact := false) :: Nil +} else Nil + artifactName := {(sv: ScalaVersion, module: ModuleID, artifact: Artifact) => val classifier = artifact.classifier match { case Some(value) => s"-$value" @@ -50,6 +53,7 @@ ThisBuild / apiMappings ++= { ThisBuild / publishTo := MornyProject.publishTo ThisBuild / credentials ++= MornyProject.publishCredentials + lazy val morny_system_lib = (project in file (MornyProject.morny_system_lib.id)) .settings( @@ -110,6 +114,10 @@ lazy val morny_coeur = (project in file(MornyProject.morny_coeur.id)) ) +lazy val dockerImageName: SettingKey[String] = settingKey[String]("Docker image name that want to built") +lazy val dockerImageTag: SettingKey[String] = settingKey[String]("Docker image tag or aka image version of the built image") +lazy val dockerBuild: TaskKey[Unit] = taskKey("Build using system docker with current version as the container tag") + lazy val root = (project in file (".")) .aggregate(morny_system_lib, morny_coeur) .settings( @@ -126,6 +134,24 @@ lazy val root = (project in file (".")) run / aggregate := false, run := { (morny_coeur / Compile / run).evaluated + }, + + dockerImageName := MornyProject.docker_image_name, + dockerImageTag := version.value, + dockerBuild := { + + val builtImageName = dockerImageName.value + val builtImageTag = (ThisProject / dockerImageTag).value + sLog.value info s"Building docker image with name $builtImageName:$builtImageTag" + + import scala.language.postfixOps + import scala.sys.process.* + s"docker build -t $builtImageName:$builtImageTag ."! + + sLog.value info s"Built docker image $builtImageName:$builtImageTag" + } ) + + diff --git a/project/MornyConfiguration.scala b/project/MornyConfiguration.scala index e6ecaef..86029d4 100644 --- a/project/MornyConfiguration.scala +++ b/project/MornyConfiguration.scala @@ -6,15 +6,17 @@ object MornyConfiguration { val MORNY_CODE_STORE = "https://github.com/Eyre-S/Coeur-Morny-Cono" val MORNY_COMMIT_PATH = "https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s" - val VERSION = "2.0.0-alpha20" + val VERSION = "2.0.0-alpha21" val VERSION_DELTA: Option[String] = None val CODENAME = "xinzheng" - val SNAPSHOT = false + val SNAPSHOT = true val GROUP = "cc.sukazyo" val GROUP_NAME = "A.C. Sukazyo Eyre" + val DOCKER_IMAGE_NAME = "coeur-morny-cono" + trait ProjectMetadata { val name: String diff --git a/project/MornyProject.scala b/project/MornyProject.scala index 75cb57a..c0751cf 100644 --- a/project/MornyProject.scala +++ b/project/MornyProject.scala @@ -44,7 +44,10 @@ object MornyProject { val group = MornyConfiguration.GROUP val group_name = MornyConfiguration.GROUP_NAME + val docker_image_name = MornyConfiguration.DOCKER_IMAGE_NAME + val publishWithFatJar = !version_is_snapshot + val publishWithDocJar = !version_is_snapshot def publishTo = MornyConfiguration.publishTo val publishCredentials = MornyConfiguration.publishCredentials