Feature Dependencies - installsAfter not respected
See original GitHub issueHello,
I’ve written a couple of features for a project I’m working on and I’ve ran into situations where I’m not sure what the best approach to take is.
For example, I have a feature which involves installing a CLI tool using npm
. Now, I’m not sure whether this feature should also install Node.js so that it is able to install the CLI tool, since I have no control over the base image, nor the included features in the devcontainer.json
file.
The power of features, as I understand, is that they can be composed together; making each serve one purpose (installing the given feature) thus providing a simple way to handle all the tooling permutations for many different developers and/or teams whilst avoiding “golden container images”; and similar perhaps in concept to buildpacks.
So it occurred to me that since devcontainers/features
already provide features for installing Node.js (and other language runtimes), it would be beneficial to make my feature dependant on the node
feature. Then I wouldn’t need to worry about which base image a developer is using, and the node
feature would be automatically included before mine, so my feature would install reliably.
Additional scenarios include:
- a Ruby gem which needs to build a native extension and thus requires
build-essential
to be installed. - a Python package, installed via
pip
, needing to ensure Python and pip are installed. - a Go CLI tool, which doesn’t have a binary distribution, installed using
go install
, needinggo
to be installed. - a
tflint
ruleset for AWS, which requires Terraform andtflint
to be installed.
I realise installing packages using a postCreateCommand
script can work, but it places the onus on the developer to know what features to include to install the given package. For example, I’m building features which install Python packages (e.g. mkdocs
) for C# .Net developers, who wouldn’t know to include the python
feature.
I imagine a devcontainer-feature.json
file including a dependsOn
property, in the same schema as the devcontainer.json
features
object.
I.e.
"dependsOn": {
"ghcr.io/user/repo/go": {},
"ghcr.io/user/repo1/go:1": {},
"ghcr.io/user/repo2/go:latest": {},
"https://github.com/user/repo/releases/devcontainer-feature-go.tgz": {
"optionA": "value"
},
"./myGoFeature": {
"optionA": true,
"optionB": "hello",
"version" : "1.0.0"
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:25 (14 by maintainers)
Top GitHub Comments
Awesome! Keep the feedback coming!
Hi @edgonmsft
Okay, I’ve updated my test repo with the changes to
installsAfter
and to use a global scenario test as mentioned above.🎉 The global scenario test is passing now; installing the python feature dependency prior to running the “pip” test.
Thanks!