Closed emk closed 7 years ago
OK, having seen the speed with cage is being ported to Windows, and looking at the predictable nature of our sample hook
script, I've decided to go for a radically different design that doesn't require any shell scripts for initialization.
Instead, our sample db.metadada.yml
will contain:
# A list of commands to run automatically when `cage up --init` is called
# on this pod. These behave as though passed to `cage run`, so the first
# argument must be the name of a pod or a service.
run_on_init:
- ["rake", "db:create"]
- ["rake", "db:migrate"]
The arguments to run_on_init
are a series of arguments to pass to cage run
internally, because—for maximum portability—you really ought to just containerize all your initialization anyway.
But this will almost certainly require us to detect and poll container ports to see when they become available. More on this soon.
Shipped in 0.1.8.
Right now, to start a project for the first time, we need to run something like:
The exact series of steps varies, and internally, we wrap cage in shell scripts so we don't get confused by which steps to take when. But it would be really nice to be able to call:
...and have cage do all that other stuff for us.
How it could work
This could be accomplished by creating
config/hooks/init.d/10_db_init.hook
and filling it with:The sneaky bit is that if we write:
...then the
--target=test
option should be trivially available to cage inside the hook script, perhaps using an environment variable (to minimize the amount of magic):Implementation tasks
Update: We have a new design in the thread below! These implementation tasks assume that design.
run_on_init
to*.metadata.yml
CommandCompose
--init
argument toup
and implement.