Skip to content
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

Is it possible to move features inside the Dockerfile, with FROM clauses for example? #6

Open
mattaereal opened this issue May 22, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@mattaereal
Copy link
Contributor

There are a lot of dev-container features that solve many things, but since the Dockerfile runs first I need some of what those features install later earlier under the Dockerfile context.

Can I somehow get them to work with FROM clauses?

@mattaereal mattaereal added enhancement New feature or request question Further information is requested labels May 22, 2024
@mattaereal mattaereal self-assigned this May 22, 2024
@mattaereal
Copy link
Contributor Author

More than one FROM clause can be used in a multi-stage build. So it should be possible to reference different builds that will end up being merged upon building. The following question will be, can features be used like that? Most of them have a Dockerfile, so it could be.

@pegahcarter
Copy link
Contributor

Exactly what features are we looking to add? Is it worth breaking them down by order of urgency / will they require a specific install order?

@mattaereal
Copy link
Contributor Author

The thing is that I'd rather use features to avoid doing a bunch of manual installations like I would rather delegate the responsibility to maintain the proper way to install node, pnpm for example. There's a feature that installs them both using nvm, which also solves the need to install nvm, which is awesome.

The thing is that since there's no devcontainer feature to install apps like Hardhat, you only have two options:

  1. You install hardhat using a devcontainer post-installation script (calling postCreateCommand), which you must download from somewhere else to avoid mounting your fs. Could also just run pnpm -i hardhat on that command inside the devcontainer (for a proper example see the article branch), but that would mean having a LOT of stuff being installed right after the creation, and will make it unmaintainable.

  2. You install hardhat and other tools in the Dockerfile. This would mean to forgo the pnpm/nvm/node feature since in this case I would NEED them to be installed before trying to install hardhat.

That's why I currently opted for the second option, since it is more performant, pollutes less the devcontainer.json, and allows me to do whatever I want*.

  • almost, installing things that require env paths is a nightmare, everything has to happen within the same context and that's why you'll see fully concatenated commands in order not to lose that context.

@pegahcarter
Copy link
Contributor

What if we stored the config in a base home directory (and use some dreaded env paths) to prevent dup installs?

To extend this, you could hop into a "hardhat" or "foundry" alias within a repo to reference only the required packages in the base dir. Other aliases could be developed to support specific package managers, node versions etc. based on the project build.

@mattaereal
Copy link
Contributor Author

I'll have to think more about this. Since hardhat has been advising not to install it globally, but rather locally on each project to avoid compatibility issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants