首页 > 解决方案 > 用于从纯 Docker 文本文件创建图像的 SBT 插件

问题描述

我想为纯 Dockerfile 文本构建图像,是否有 SBT 插件可以让我指定自己的 docker 文件。

标签: scalasbtsbt-native-packagersbt-pluginsbt-docker

解决方案


I don't really see a need for a plugin here. The simplest way is to just create a sbt task which calls docker process in the shell. Doing so in sbt is quite simple, take a look at this answer: How to execute a bash script as sbt task?

Something like this:

lazy val yourDockerTask = taskKey[Unit]("Runs docker build")

yourDockerTask := {
  "docker build ." !
}

Then you can call the task you just created from the sbt shell.


推荐阅读