-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add devcontainer configuration #8213
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
base: main
Are you sure you want to change the base?
Conversation
spoiler: i don't know much about this |
Adds basic devcontainer configuration using Microsoft's rust:1-1-bookworm container. The existing recommended extensions are included.
b7ef1ba
to
481765a
Compare
It shouldn't be too difficult to set up some task to build the devcontainer (like a standard container) and then run some tests inside of it. I haven't set anything like that up and am not very familiar with GitHub CI in general. Are containers currently being used anywhere in this project? |
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.
I also was about to submit a fairly similar PR shortly, hence my comments on things I've found here. (I'm still getting a better understanding of the setup also)
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "./.devcontainer/postCreateCommand.sh" |
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.
It may be worth (from the perspective of the next user to use the dev container at least) using a dockerfile here instead of doing this post build.
sudo apt update && sudo apt install -y --no-install-recommends \ | ||
clang 8000 span> |
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.
If moving this to a dockerfile, makes sure to also remove the cache to reduce the image size
#!/bin/sh | ||
|
||
sudo apt update && sudo apt install -y --no-install-recommends \ | ||
clang |
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.
This should also probably clone the GNU coreutils as it takes a reasonable amount of time to clone, and a git fetch would likely be much faster.
The expectation is that the repo ends up one level up from this workspace in /workspace/gnu
git clone --recurse-submodules https://github.com/coreutils/coreutils.git "/workspaces/gnu"
This either requires sudo or root as /workspace is 644 root:root. So it's likely easiest to run as root - unsure if that's a problem within a container. Obviously you wouldn't want this on a physical machine
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" |
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.
See note below about root user.
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm", |
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.
See note below about using a docker file
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | |
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm", | |
"build": { | |
// Path is relative to the devcontainer.json file. | |
"dockerfile": "Dockerfile" | |
},``` |
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/rust | ||
{ | ||
"name": "Rust", |
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.
"name": "Rust", | |
"name": "Uutils coreutils", |
"extensions": [ | ||
// cspell:disable-next-line | ||
"foxundermoon.shell-format", | ||
"streetsidesoftware.code-spell-checker" |
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.
I noticed that this seems to try to load the cspell config from /workspaces/coreutilsvscode/cspell.json
.
Adding a ./
to the setting in .vscode/settings.json
to { "cSpell.import": ["./.vscode/cspell.json"] }
fixes this so that correctly loads /workspaces/coreutils/.vscode/cspell.json
. I'm guessing this is bug in the extension perhaps?
// Use 'mounts' to make the cargo cache persistent in a Docker Volume. | ||
// "mounts": [ | ||
// { | ||
// "source": "devcontainer-cargo-cache-${devcontainerId}", | ||
// "target": "/usr/local/cargo", | ||
// "type": "volume" | ||
// } | ||
// ] |
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.
Turning this on seems fairly useful as it means that you can rebuild the devcontainer without having to redownload the crates all the time. Instead they're cached in a volume that is stored locally. This saves a fair bit of time.
Adds basic devcontainer configuration using Microsoft's rust:1-1-bookworm container.
The existing recommended extensions are included.
Suggested here #6947 (comment), this devcontainer was very useful to me to test a small change.
I wasn't sure how to best format the commit message for this change. Please let me know if you'd like me to amend it.