8000 Add devcontainer configuration by deadmeu · Pull Request #8213 · uutils/coreutils · GitHub
[go: up one dir, main page]

Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deadmeu
Copy link
Contributor
@deadmeu deadmeu commented Jun 18, 2025

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.

@sylvestre
Copy link
Contributor

spoiler: i don't know much about this
it is possible to test such containers in github ci ?

Adds basic devcontainer configuration using Microsoft's
rust:1-1-bookworm container.

The existing recommended extensions are included.
@deadmeu deadmeu force-pushed the add-devcontainer branch from b7ef1ba to 481765a Compare June 18, 2025 08:40
@deadmeu
Copy link
Contributor Author
deadmeu commented Jun 18, 2025

spoiler: i don't know much about this it is possible to test such containers in github ci ?

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?

Copy link
@joshka joshka left a 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)

Comment on lines +32 to +33
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "./.devcontainer/postCreateCommand.sh"
Copy link

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.

Comment on lines +3 to +4
sudo apt update && sudo apt install -y --no-install-recommends \
clang
Copy link

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

Comment on lines +1 to +4
#!/bin/sh

sudo apt update && sudo apt install -y --no-install-recommends \
clang
Copy link

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

Comment on lines +38 to +39
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Copy link

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.

Comment on lines +5 to +6
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm",
Copy link

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

Suggested change
// 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",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "Rust",
"name": "Uutils coreutils",

"extensions": [
// cspell:disable-next-line
"foxundermoon.shell-format",
"streetsidesoftware.code-spell-checker"
Copy link

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?

Comment on lines +17 to +24
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
// "mounts": [
// {
// "source": "devcontainer-cargo-cache-${devcontainerId}",
// "target": "/usr/local/cargo",
// "type": "volume"
// }
// ]
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0