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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Add devcontainer configuration
Adds basic devcontainer configuration using Microsoft's
rust:1-1-bookworm container.

The existing recommended extensions are included.
  • Loading branch information
deadmeu committed Jun 18, 2025
commit 481765a378ad5d15a2c135cd653569936773c78f
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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",

// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm",
Comment on lines +5 to +6
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"
},```

"customizations": {
"vscode": {
"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?

]
}
},

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


// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "./.devcontainer/postCreateCommand.sh"
Comment on lines +32 to +33
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.


// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Comment on lines +38 to +39
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.

}
4 changes: 4 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sudo apt update && sudo apt install -y --no-install-recommends \
clang
Comment on lines +3 to +4
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
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

2 changes: 2 additions & 0 deletions .vscode/cspell.dictionaries/jargon.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ denoland
deque
dequeue
dev
devcontainer
devcontainers
devs
discoverability
duplicative
Expand Down
Loading
0