How to push/build a docker image in release process via sbt-release

删除回忆录丶 提交于 2019-12-06 13:14:23

问题


I'm a newbie for scala.

I used sbt-release to control release process and sbt-docker to build/publish a docker image.

I can release a specific version via sbt release and build/publish a docker image via sbt docker or `sbt dockerBuildAndPush'

If I wanna release a specific version, I need to

  1. execute sbt release
  2. remember the release version and modify docker image tag with the release version
  3. execute sbt dockerBuildAndPush

But it's so tedious...

I wanna add build/publish docker image into release process.

For example:

I define my release process in build.sbt

val publishDocker = ReleaseStep(action = st => {
  // 1. get release version from sbt-release
  // 2. add release version to docker image tag
  // 3. push docker image to aws ecr
})

releaseProcess := Seq[ReleaseStep](
  checkSnapshotDependencies,            
  inquireVersions,                      
  runTest,                                
  setReleaseVersion,                     
  commitReleaseVersion,                   
  tagRelease,                            
  publishDocker,                      
  setNextVersion,                        
  commitNextVersion,                      
  pushChanges                            
)

But I have no idea how to implement publishDocker function.

Thanks for your help~


回答1:


@ed Thanks for your advice and I solved it by myself :>

This is my sbt: https://gist.github.com/pandaforme/e378dc3f1f32aa252b14e40937491e9c

I just execute sbt release and it'll automatically compile, generate release version, build and push docker image, etc.




回答2:


I'm not familiar with sbt-docker but you can get the version from the st: State parameter:

val publishDocker = ReleaseStep(action = st => {
  // 1. get version from sbt
  // (it was set by sbt-release in setReleaseVersion)
  val extracted = Project.extract(st)
  val version:String = extracted.get(sbt.Keys.version)

})


来源:https://stackoverflow.com/questions/37418201/how-to-push-build-a-docker-image-in-release-process-via-sbt-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!