Skip to content

Commit ee3ead1

Browse files
evnchnclaudefalkoschindler
authored
Add GitHub CLI and pre-commit hooks to devcontainer (zauberzeug#5741)
### Motivation The devcontainer currently lacks GitHub CLI (`gh`) integration and pre-commit hook setup, making it harder for contributors to interact with GitHub (e.g., creating PRs, reviewing issues) and to catch linting/formatting issues before pushing. ### Implementation - **Dockerfile**: Added `gh` (GitHub CLI) to the installed packages. - **devcontainer.json**: - Added a persistent named volume (`gh-config`) mounted at `~/.config/gh` so that `gh auth` tokens survive container rebuilds. - Extended `postCreateCommand` to fix volume ownership, run `pre-commit install`, and prompt for `gh auth login` if not already authenticated. - **CONTRIBUTING.md**: Updated the devcontainer setup instructions to note the GitHub authentication prompt on first launch. ### Progress - [x] I chose a meaningful title that completes the sentence: "If applied, this PR will..." - [x] The implementation is complete. - [x] If this PR addresses a security issue, it has been coordinated via the [security advisory](https://github.com/zauberzeug/nicegui/security/advisories/new) process. - [x] Pytests have been added (or are not necessary). - [x] Documentation has been added (or is not necessary). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Falko Schindler <falko@zauberzeug.com>
1 parent 59f8c50 commit ee3ead1

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
55

66
# Install packages
77
RUN apt-get update && apt-get install --no-install-recommends -y \
8-
sudo git chromium chromium-driver \
8+
sudo git chromium chromium-driver gh \
99
&& rm -rf /var/lib/apt/lists/*
1010

1111
# Install uv

.devcontainer/devcontainer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,12 @@
3535
},
3636
// More info: https://aka.ms/dev-containers-non-root.
3737
"remoteUser": "vscode",
38-
"postCreateCommand": "uv sync"
38+
"mounts": [
39+
{
40+
"source": "nicegui-gh-config",
41+
"target": "/home/vscode/.config/gh",
42+
"type": "volume"
43+
}
44+
],
45+
"postCreateCommand": "bash .devcontainer/post-create.sh"
3946
}

.devcontainer/post-create.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Fix ownership of .config/gh (Docker volume mounts it as root)
5+
sudo chown vscode:vscode /home/vscode/.config
6+
sudo chown -R vscode:vscode /home/vscode/.config/gh
7+
8+
uv sync
9+
uv run pre-commit install
10+
11+
# Authenticate with GitHub CLI if not already logged in
12+
gh auth status >/dev/null 2>&1 || gh auth login -h github.com -p https -w || true

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The simplest way to setup a fully functioning development environment is to star
7373
1. Ensure you have VS Code, Docker and the Dev Containers extension installed.
7474
2. Open the project root directory in VS Code.
7575
3. Press `F1`, type `Dev Containers: Open Folder in Container`, and hit enter (or use the bottom-left corner icon in VS Code to reopen in container).
76-
4. Wait until image has been build.
76+
4. Wait until the image has been built. (On first launch, watch the terminal for a GitHub authentication prompt.)
7777
5. Happy coding.
7878

7979
### Locally

0 commit comments

Comments
 (0)