Skip to content
Draft
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
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"mounts": [
"source=copilot-cli-credentials,target=/home/vscode/.config/github-copilot,type=volume"
],
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -13,5 +16,5 @@
}
},
"onCreateCommand": "pip install pytest && npm install -g @github/copilot",
"postStartCommand": "echo '✅ Python, pytest, GitHub CLI, and Copilot CLI are ready. Run: cd samples/book-app-project && python book_app.py help'"
"postStartCommand": "bash .devcontainer/startup.sh"
}
7 changes: 7 additions & 0 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
echo '✅ Python, pytest, GitHub CLI, and Copilot CLI are ready. Run: cd samples/book-app-project && python book_app.py help'
if ls ~/.config/github-copilot/*.json &>/dev/null; then
echo '🔑 Copilot CLI credentials found — you are already signed in.'
else
echo '🔑 No credentials found — open the Copilot CLI session (run: copilot) and then type /login to authenticate.'
fi
39 changes: 39 additions & 0 deletions 00-quick-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,45 @@ After trusting the folder, you can sign in with your GitHub account.

**Tip**: The sign-in persists across sessions. You only need to do this once unless your token expires or you explicitly sign out.

### Persisting Credentials in Dev Containers

When you work inside a **dev container** (locally or via a Codespace), credentials can be lost when the container is rebuilt — because the container's file system starts fresh. Here is how each environment handles this:

| Environment | What happens to credentials |
|---|---|
| **Local install** (no container) | Credentials persist in `~/.config/github-copilot/` on your machine |
| **GitHub Codespace** | Credentials persist within the *same* Codespace; creating a *new* Codespace requires one-time re-authentication |
| **Local dev container** | Credentials are stored in a named Docker volume (`copilot-cli-credentials`) that survives container rebuilds automatically |

#### How credential persistence works in this repo's dev container

The `.devcontainer/devcontainer.json` in this repo mounts a named Docker volume at the path where Copilot CLI stores its credentials:

```json
"mounts": [
"source=copilot-cli-credentials,target=/home/vscode/.config/github-copilot,type=volume"
]
```

**What this means for you:**

- **First time**: Open the dev container, start the Copilot CLI session (`copilot`), and then type `/login` inside the session to authenticate once.
- **After a rebuild**: Your credentials are loaded automatically from the volume — no need to log in again.
- **Start fresh**: To reset credentials, delete the named volume from Docker Desktop (Volumes tab) or run `docker volume rm copilot-cli-credentials` in your terminal, then re-authenticate.

> 💡 **Status check at startup**: Each time the container starts, the terminal shows a 🔑 line telling you either that credentials were found (and you are already signed in) or that no credentials were found (and you need to run `/login`).

#### Re-authenticating when needed

If you see an authentication error, or if you created a new Codespace, simply sign in again:

```bash
copilot
> /login
```

Follow the same device-flow steps described above.

---

## Verify It Works
Expand Down