-
Notifications
You must be signed in to change notification settings - Fork 37
Add on_start label for running a command every time the container starts #219
Conversation
Adding the `on_open` label to an image will cause sail to exec that command inside of the container's project directory every time it starts a container. Added the new label to the documentation.
Still need to write tests for this before this can be merged, but I'd like to hear any thoughts before doing so. |
Maybe this label should be changed to |
This looks good if you want to start working on tests for it. I agree, I think we should name it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on_start
definitely makes more sense
- Rename the on_open label to on_start - Use docker cli directly to run on_start label rather than docker API - Drop (*runner).runInContainer(...) in favour of internal/dockutil - Drop expandDir(...) in favour of an existing function
Is the only way to write tests for this to make a new GitHub repository with an |
To test it, you could add an example hat showing how to use the label, maybe just create a file in the container or something, then use that example hat in a test and validate that whatever changes the on_start command did actually occurred after the container is started |
I'm having an issue running the tests on my machine if I run all of them at the same time. Almost every time a random
If I run tests with |
@nathanpotter Could you please approve the tests? |
Adding the
on_open
label to an image will cause sail to exec that command inside of the container's project directory every time it creates a container.Added the new label to the documentation.
When this was discussed in #191, the concept was a
.sail/on_open
file rather than a label. This PR uses a label instead of a file, as (in my opinion) a label seems to be a more "sail way" of doing this. As using a label for this functionality hasn't been discussed, this PR should not be merged until this is discussed.Emulating the
.sail/on_open
file is as simple asLABEL on_open ".sail/on_open"
, and making sure that.sail/on_open
has a shebang and is executable.Closes #191.