Reputation: 2912
I'm trying to dockerize my scala application using the sbt-native-packager plugin. I've added the proper elements to build.sbt (see below).
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.6")
and
enablePlugins(JavaAppPackaging)
I then run (succesfully):
sbt stage
And then I run:
sbt docker:publishLocal
But it fails with this error:
[error] invalid argument "my-service:3.0.3-b29+2-0d2a26e3+20210402-1141" for "-t, --tag" flag: invalid reference format
[error] See 'docker build --help'.
[error] stack trace is suppressed; run 'last Docker / publishLocal' for the full output
[error] (Docker / publishLocal) Nonzero exit value: 125
[error] Total time: 18 s, completed Apr 2, 2021 11:43:32 AM
Q: What does this error mean?
This is my build.sbt:
name := """my-service"""
organization := "my.org"
scalaVersion := "2.12.4"
dynverVTagPrefix in ThisBuild := false
lazy val root = (project in file("."))
.enablePlugins(JavaAppPackaging)
.enablePlugins(PlayScala)
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "controllers"
)
libraryDependencies += guice
libraryDependencies += jdbc
libraryDependencies += ws
libraryDependencies += "mysql" % "mysql-connector-java" % "8.0.14"
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.3"
libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.1"
libraryDependencies ++= Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test,
jdbc % Test
)
Upvotes: 1
Views: 719
Reputation: 6647
The error is thrown because +
is not a valid character to have in a docker tag.
You either need to set the version properly if it is a full published version, or add the dynver plugin and something like this to your build.sbt to replace the +
with an allowed character.
// Changes DynVer version string to work with Docker
lazy val dynVerSettings = {
Seq(
version ~= (_.replace('+', '-')),
dynver ~= (_.replace('+', '-'))
)
}
Upvotes: 0
Reputation: 2912
The solution was that the build.sbt was missing the version! The version seems to be used as the docker tag!
I only needed to add the version to the top of the build.sbt and the error went away, like this:
name := """my-service"""
organization := "my.org"
scalaVersion := "2.12.4"
version := "0.1.0-SNAPSHOT"
Upvotes: 2