-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Docker "--volume" mounts during integration tests. #870
Conversation
Would it perhaps make sense to use an interface similar to how we currently handle environment variables, e.g. See this PR for a full implementation using that approach. |
This changeset supports specifying multiple ContainerConfig::new().volumes(["/shared/cache:/workspace/cache", "/shared/models:/workspace/models"]) …would generate the command: docker run --volume /shared/cache:/workspace/cache --volume /shared/models:/workspace/models Passing these |
@runesoerensen if y'all would prefer that more granular interface implementation, that's your call. We can close this PR and use yours instead. I just hope to have this implemented/merged, so that I can switch my dependent project back to using the main distribution of libcnb.rs, instead of my branch |
The implementation I proposed actually also supports specifying multiple volume/bind mounts (and arguably in a way that's more consistent with the way the parameters are passed to the docker CLI). I've since changed the semantics a bit to use ContainerConfig::new()
.bind_mount(
PathBuf::from("/shared/cache"),
PathBuf::from("/workspace/cache"),
)
.bind_mount("/shared/models", "/workspace/models"); // Less verbose, but retaining the `PathBuf` semantics. My primary motivation for suggesting this approach is that it's more consistent with how On that note, calling the Not looking to over-engineer things here, but as mentioned above I changed the implementation from using the Definitely open to learn how my proposed approach here may be flawed (I'm still a bit of a Rust rookie after all :)). And I hear you on wanting to get some solution implemented -- will ask the team to take a look and chime in on the best way forward! |
Thanks @runesoerensen for the deeper explanation, evidence, and alternative PR. I am totally fine with switching from volumes to bind_mounts. That sounds good 👍 |
Ok great, I've merged the PR and cut a new release, so you can switch back to using the version published on crates.io. I'll close this PR as the functionality is now supported - thanks for your work on this @mars ! |
This enables using Docker volumes in integration tests, by implementing
libcnb_test::ContainerConfig::volumes()
, which generates--volume XXXXX
arguments on the underlyingdocker run
command.