Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

[idea] Switch from sbt-docker to sbt-native-packager #771

Open
andreaTP opened this issue Oct 8, 2020 · 1 comment
Open

[idea] Switch from sbt-docker to sbt-native-packager #771

andreaTP opened this issue Oct 8, 2020 · 1 comment

Comments

@andreaTP
Copy link
Contributor

andreaTP commented Oct 8, 2020

Currently, Cloudflow relies on sbt-docker internally(e.g. the operator image) and for the buildApp task of the sbt plugin.

This causes small issues, especially with caches, such as buildApp task needs to be run after a clean when you change Cloudflow version (I can confirm that this is automatically solved by sbt-native-packager).

Also sbt-native-packager is a more widely used and maintained project.

Our dependency on sbt-docker is the extraction of the digest that can be replaced by something like:

val testPublish = taskKey[String]("test")
testPublish := {
  val _ = publishLocal.value
  val alias = dockerAliases.value

  var digest: String = null
  import sbt.internal.util.ManagedLogger
  class MyManagedLogger(ml: ManagedLogger) extends ManagedLogger(ml.name, ml.channelName, ml.execId, null) {
    val PushedImageDigestSha256 = ".* digest: sha256:([0-9a-f]+) .*".r

    override def log(level: Level.Value, message: => String): Unit = {
      message match {
        case PushedImageDigestSha256(d) => digest = d
        case _ =>
      }
    }
  }
  val log = new MyManagedLogger(streams.value.log)
  val execCommand = dockerExecCommand.value
  alias.foreach { aliasValue =>
    _root_.com.typesafe.sbt.packager.docker.DockerPlugin.publishDocker(execCommand, aliasValue.toString, log)
  }

  digest
}

On the downside this is going to be a breaking change for the user.

@seglo
Copy link
Contributor

seglo commented Oct 13, 2020

Oh, cloudflow was using sbt-native-packager, but I guess it was changed at some point?

One thing to keep an eye out if we do this is that the images are still built efficiently. The app artifacts should be in a single layer so only 1 small layer change is required for each new image push. sbt-native-packager (IIRC) puts all artifacts in a single directory (including dependencies) which can result in a bigger layer every time the app is changed.

This has been a topic of some debate to make this functionality the default in sbt-native-packager for Docker targets. sbt/sbt-native-packager#1310

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants