Writing a plan for sbt


Hi there,

I have just discovered Habitat, and after inspecting some of the existing core plans, I had a go at building one for sbt.

I thought of sharing this here, hoping to get some feedback and maybe contributing it upstream later on. Specifically, I am a bit uncertain on the following.

Why can’t I export the plan as a docker container?

I can verify that the plan builds sbt correctly by running:

hab pkg exec afiore/sbt/1.1.6 sbt

However, when I try exporting the package as a docker container (in hab studio), I get the error below. What is a primary service and should sbt be one of those?

[2][default:/src:1]# hab pkg export docker results/afiore-sbt-1.1.6-20180730072046-x86_64-linux.hart
✗✗✗ A primary service package could not be determined from: ["afiore/sbt"]. At least one package with a run hook must be provided.

What do I do next?

what else do you recommend to do when developing a new package before opening a PR to the core repo?


Currently, only habitat packages that are services can be exported as docker containers. That means a run hook or a $pkg_svc_run is needed. I’ve heard chatter about this possibly changing in the future.

If you want to do this now, here’s how I’d do it: write a Dockerfile that takes a lean image like alpine, uses the curl|bash to install habitat, then runs the hab pkg install command of your choice. You could even choose to binlink your executable to eliminate the hab pkg exec call.


Thanks for the clarification @HT154! Also, the way around you suggest sounds pretty good


Here is an example of what @HT154 is talking about as a stop-gap https://github.com/habitat-sh/habitat/blob/master/components/rootless_studio/default/Dockerfile