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

RFC: Add dev container configuration #12306

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
edd8c9f
Add dev container configuration
hoechenberger Dec 18, 2023
54b159b
Change VNC password to "mne"
hoechenberger Dec 20, 2023
7d5c6a2
Fix bash support
hoechenberger Dec 20, 2023
533db90
Don't install git from PPA [ci skip]
hoechenberger Dec 20, 2023
88fb767
Git is actually already included in the base image, no need to add itโ€ฆ
hoechenberger Dec 21, 2023
c2ef194
Add more comments
hoechenberger Dec 21, 2023
4e7d48f
Use custom username
hoechenberger Dec 22, 2023
c9fb83a
Add git and pip zsh plugins
hoechenberger Dec 22, 2023
1d475dc
Merge branch 'main' into devcontainer
hoechenberger Dec 22, 2023
7732c1b
Better comments [ci skip]
hoechenberger Dec 22, 2023
c2da3f2
Add comment [ci skip]
hoechenberger Dec 22, 2023
42714c8
Simplify formatting rules and disbale format-on-type
hoechenberger Jan 17, 2024
f758f91
Add git blame ignore revs
hoechenberger Jan 17, 2024
c2ce81f
Merge branch 'main' of https://github.com/mne-tools/mne-python into dโ€ฆ
hoechenberger May 25, 2024
865484b
Merge branch 'main' into devcontainer
hoechenberger May 25, 2024
5b90440
Merge branch 'devcontainer' of https://github.com/hoechenberger/mne-pโ€ฆ
hoechenberger May 25, 2024
7f64bae
Iterate
hoechenberger May 27, 2024
78628b6
Update .gitignore
hoechenberger May 27, 2024
5727408
Create MNE data dir on the host if it doesn't exist
hoechenberger May 27, 2024
ae7afc8
Fix image spec
hoechenberger May 27, 2024
831fcfa
Add git settings
hoechenberger May 27, 2024
b736ab4
Use ruff from Python env
hoechenberger May 27, 2024
a911699
Reorder
hoechenberger May 27, 2024
436fa77
Mount host's MNE data dir
hoechenberger May 27, 2024
f74476c
Formatting
hoechenberger May 27, 2024
7fb00e4
Reorganiz
hoechenberger May 27, 2024
35d0ff2
pre-commit installation
hoechenberger May 27, 2024
77d33b8
pre-commit setup and passwordless VNC
hoechenberger May 27, 2024
b963171
We need VTK from conda-forge as well
hoechenberger May 27, 2024
90859fe
PySide6
hoechenberger May 27, 2024
09bba5c
Re-order and remove Mamba
hoechenberger May 28, 2024
92ab0e6
Newest desktop-lite includes my patches for passwordless login
hoechenberger May 30, 2024
e77ebb6
Install psutil and cftime from conda-forge (no wheels available)
hoechenberger May 30, 2024
7f23b05
No wheel yet for OpenMEEG
hoechenberger May 30, 2024
27f942d
Merge branch 'main' of https://github.com/mne-tools/mne-python into dโ€ฆ
hoechenberger May 30, 2024
74e3a1f
stashMore logging
hoechenberger May 30, 2024
ed0738a
Disable Ruff's Rust-based language server
hoechenberger May 30, 2024
91ae09e
Remove Resource Monitor extension
hoechenberger May 31, 2024
053f349
Add tasks and debug configuration
hoechenberger May 31, 2024
6c956e7
Linebreak
hoechenberger May 31, 2024
010f77e
Install nitime from conda, too
hoechenberger May 31, 2024
c8c190f
Download pre-commit environments when setting up hooks
hoechenberger May 31, 2024
be4b239
nitime is not on conda-forge
hoechenberger May 31, 2024
045dbeb
Better xmessage
hoechenberger May 31, 2024
f661923
Harmonize scripts
hoechenberger May 31, 2024
34e508c
Better task handling, install openmeeg from PyPI
hoechenberger Jun 3, 2024
17bfca4
Merge branch 'main' of https://github.com/mne-tools/mne-python into dโ€ฆ
hoechenberger Jun 5, 2024
a92aebf
Phrasing
hoechenberger Jun 6, 2024
b945edc
Use uv for installation
hoechenberger Jun 6, 2024
0d90a77
Merge branch 'main' of https://github.com/mne-tools/mne-python into dโ€ฆ
hoechenberger Jun 6, 2024
2e96695
Add spaces
hoechenberger Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This Dockerfile is currently only used to enforce use of x86 image on ARM64 CPUs (Apple Silicon)
# See aarch64 migration on https://conda-forge.org/status/, which is currently blocking us.
FROM --platform=amd64 mcr.microsoft.com/devcontainers/base:debian-11
hoechenberger marked this conversation as resolved.
Show resolved Hide resolved
150 changes: 150 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"name": "mne-dev",
// "image": "mcr.microsoft.com/devcontainers/base:debian-11",
"build": { "dockerfile": "Dockerfile" },
"containerEnv": {
"PYTHONNOUSERSITE": "true", // Make Python ignore the user's site-packages folder if it exists
"XDG_RUNTIME_DIR": "/home/vscode/.cache/xdgr"
hoechenberger marked this conversation as resolved.
Show resolved Hide resolved
},
"features": {
// See https://containers.dev/features
// APT packages
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": "mesa-utils,libegl1,^libxcb.*-dev,libx11-xcb-dev,libglu1-mesa-dev,libxrender-dev,libxi-dev,libxkbcommon-dev,libxkbcommon-x11-dev"
},
Copy link
Member Author

Choose a reason for hiding this comment

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

this could probably be trimmed down a little? not sure.

// Git
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "true"
hoechenberger marked this conversation as resolved.
Show resolved Hide resolved
},
// Conda and Mamba
"ghcr.io/mamba-org/devcontainer-features/micromamba:1": {
"channels": "conda-forge",
"packages": "conda mamba ipython jupyterlab mne"
},
// Docker interface with host's Docker service
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
// Zsh plugins
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
"plugins": "zsh-autosuggestions zsh-syntax-highlighting history-substring-search",
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-syntax-highlighting"
Copy link
Member

Choose a reason for hiding this comment

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

why are these needed? Will the user ever access a terminal in the container (and if so, won't it be a BASH terminal by default?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, of course :) It's a complete development environment, and if you open a terminal, it will open a "remote" shell inside the Docker container.

The default shell is zsh with oh-my-zsh.

I'm trying to provide a nice and comfy shell experience through these plugins.

Copy link
Member

Choose a reason for hiding this comment

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

I'm trying to provide a nice and comfy shell experience through these plugins.

Another word for "comfy" is "familiar". I don't necessarily object to including zsh alongside bash but I'm dubious about making zsh the default here.

Copy link

Choose a reason for hiding this comment

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

MacOS users have zsh as the default shell and zsh is very close to bash.

Copy link
Member

Choose a reason for hiding this comment

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

yes, I know that since 2019 macOS uses zsh as the default shell. And I've heard that they're similar. What I'm questioning is why tailor the experience in a linux container to feel familiar to macOS users. Sticking with BASH seems like the natural default choice, and deviation from that feels like it needs to be justified.

Copy link
Member Author

Choose a reason for hiding this comment

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

Both shells are first-class citizens in the MS dev containers. By default, both are shipped, hence I'm shipping both too. The plugins listed here make the zsh experience better and superior to the Bash experience. I have not yet decided which shell shall be the default one. However, I'm surprised this seems to be so controversial. VS Code clearly displays which shell is being used, and when spawning a new terminal, one can select the shell from a dropdown menu. Besides, I don't see how the choice of shell matters as long as one doesn't do shell programming; and this is an MNE dev container, no generic Linux Shell Programming dev container. Like I said, I haven't decided yet which default I think would be best; but It's quite obvious to me though that the zsh prompt looks better and the shell provides more help during interactive use (history substring search being one of those invaluable features; git support being another).

Copy link
Member

Choose a reason for hiding this comment

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

I have not yet decided which shell shall be the default one.

This is news to me; you originally set zsh as default (which I noticed at the time), then removed that setting in 7d5c6a2 after my earlier comments. It seems a bit disingenuous to now say "why is this so controversial, they're both included and I haven't chosen a default".

That said, I'm happy if both are included and it's easy (and documented) for users to switch the shell they get in their container. Ideally this would be a one-time config (not something that needs doing every time the container is launched) if that's possible

Copy link
Member Author

Choose a reason for hiding this comment

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

This is news to me; you originally set zsh as default (which I noticed at the time), then removed that setting in 7d5c6a2 after my earlier comments

Ah, I see!! No, this was actually a misunderstanding. The default login shell always was Bash, and the setting you're referring to controls which shell should be spawned by default when creating a new terminal without explicitly selecting a shell. This was in fact an accidental setting that I copied over from another dev container config I'm working with. But this setting never changed the (login) default shell to zsh, nor dropped bash or something :) I had however forgotten to properly set up mamba and conda for bash โ€“ย something I realized and fixed after your comment / question.

That said, I'm happy if both are included and it's easy (and documented) for users to switch the shell they get in their container. Ideally this would be a one-time config (not something that needs doing every time the container is launched) if that's possible

Yep, I'm open for this! for now I'm really still trying to make things work and experimenting a bit! Let's save the heated debates for later! ๐Ÿ˜๐Ÿค—

Oh and, happy holidays to you all!!!

},
// Desktop and VNC access
"ghcr.io/devcontainers/features/desktop-lite:1": {}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

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

seems like fertile ground for bikeshedding. Is there a way for the container to pick up the user's local settings? If not, then can you indicate which of these settings are truly necessary for the container to work, which are not necessary but clearly a good idea (e.g., don't restore port forwards?), and which are your preferences (perhaps "format on type" fits here)?

"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.formatOnType": true,
"editor.renderWhitespace": "trailing",
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.rulers": [88],
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestEnabled": true,
"python.defaultInterpreterPath": "/opt/conda/bin/python",
"debugpy.debugJustMyCode": false,
"terminal.integrated.defaultProfile.linux": "zsh", // Make zsh the default shell.
// Screencast settings
"screencastMode.keyboardOverlayTimeout": 5000,
"screencastMode.mouseIndicatorSize": 50,
// Disable telemetry and experiments
"telemetry.telemetryLevel": "off",
"gitlens.telemetry.enabled": false,
"redhat.telemetry.enabled": false,
"workbench.enableExperiments": false, // Should not be necessary if telemetry is off, but let's make it explicit.
// Avoid accumulation of unused forwarded ports.
"remote.restoreForwardedPorts": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// Python Development
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"charliermarsh.ruff",
// MNE-Python snippets
"hoechenberger.mne-python-extension",
// "ms-python.debugpy@prerelease", // TODO remove prerelease tag once stable release is published
// JavaScript & TypeScript Development
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
// Git
"GitHub.vscode-pull-request-github",
"eamodio.gitlens",
// Docker
"ms-azuretools.vscode-docker",
// TOML
"tamasfe.even-better-toml",
// YAML
"redhat.vscode-yaml",
// Spell checking
"streetsidesoftware.code-spell-checker",
// Resource monitor
"mutantdino.resourcemonitor",
// Path / filename autocomplete
"ionutvmi.path-autocomplete"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [5901, 6080],
"portsAttributes": {
"5901": {
"label": "vnc"
},
"6080": {
"label": "vnc web"
}
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": {
// Initialize shells to use conda and mamba
"init-mamba-shell": "mamba init --quiet zsh",
// Force pip to always install "globally": This will work in a virtual environment, but fail with the system Python, which is
// precicely what we want: prevent users from accidentally cluttering their user site-packages folder
"disable-pip-user-installs": "pip config set install.system true",
// Install MNE in editabe mode, and set up pre-commit hooks
"install-mne-editable": "pip install -e '.[full,dev,test_extra]' && pre-commit install",
// Create XDG_RUNTIME_DIR
"create-xdg-runtime-dir": "mkdir -p -m 0700 $XDG_RUNTIME_DIR"
},
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"postStartCommand": {
// Do all git-config-related things here, otherwise we may run into problems; see:
// https://github.com/microsoft/vscode-remote-release/issues/6810
//
// Set git default branch name
"set-git-default-branch-name": "git config --global init.defaultBranch main",
// Work around "dubious ownership in repository" error
"fix-git-ownership-issue": "git config --global --add safe.directory ${containerWorkspaceFolder}",
// Use VS Code as default git editor, diff, and merge tool
"set-vscode-as-git-editor": "git config --global core.editor 'code --wait --reuse-window'",
"add-vscode-as-git-difftool": "git config --global --replace-all difftool.default-difftool.cmd 'code --wait --diff $LOCAL $REMOTE'",
"set-vscode-as-git-difftool": "git config --global --replace-all diff.tool default-difftool",
"add-vscode-as-git-mergetool": "git config --global --replace-all mergetool.code.cmd 'code --wait --merge $REMOTE $LOCAL $BASE $MERGED'",
"set-vscode-as-git-mergetool": "git config --global --replace-all merge.tool code",
// Show indicator for "dirty" git repositories in the shell prompt.
// This can be slow on large repositories and should be disabled in that case.
"enable-dirty-git-repo-indicator": "git config --global --replace-all devcontainers-theme.show-dirty 1"
hoechenberger marked this conversation as resolved.
Show resolved Hide resolved
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ cover
.venv/
venv/
*.json
!/.devcontainer/devcontainer.json
hoechenberger marked this conversation as resolved.
Show resolved Hide resolved
!codemeta.json
.hypothesis/
.ruff_cache/
Expand Down