Skip to content

Commit d5c4bf0

Browse files
authored
Adopt Devcontainer for Development Environment (#81)
* chore: add devcontainer setting * docs: add Dev Container setup instructions to README and create DEVCONTAINER.md
1 parent 6a648b8 commit d5c4bf0

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

.devcontainer/devcontainer.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
3+
{
4+
"name": "Rust",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers/features/node:1": {},
9+
"ghcr.io/devcontainers/features/python:1": {
10+
"version": "3.10",
11+
"toolsToInstall": "uv"
12+
}
13+
},
14+
// Configure tool-specific properties.
15+
"customizations": {
16+
"vscode": {
17+
"settings": {
18+
"editor.formatOnSave": true,
19+
"[rust]": {
20+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
21+
}
22+
}
23+
}
24+
},
25+
// Use 'postCreateCommand' to run commands after the container is created.
26+
"postCreateCommand": "uv venv"
27+
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
28+
// "mounts": [
29+
// {
30+
// "source": "devcontainer-cargo-cache-${devcontainerId}",
31+
// "target": "/usr/local/cargo",
32+
// "type": "volume"
33+
// }
34+
// ]
35+
// Features to add to the dev container. More info: https://containers.dev/features.
36+
// "features": {},
37+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
38+
// "forwardPorts": [],
39+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
40+
// "remoteUser": "root"
41+
}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,7 @@ See [examples](examples/README.md)
188188

189189
- [MCP Specification](https://spec.modelcontextprotocol.io/specification/2024-11-05/)
190190
- [Schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts)
191+
192+
## Development with Dev Container
193+
194+
See [docs/DEVCONTAINER.md](docs/DEVCONTAINER.md) for instructions on using Dev Container for development.

docs/DEVCONTAINER.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## Development with Dev Container and GitHub Codespaces
2+
3+
This repository provides a Dev Container to easily set up a development environment. Using Dev Container allows you to work in a consistent development environment with pre-configured dependencies and tools, whether locally or in the cloud with GitHub Codespaces.
4+
5+
### Prerequisites
6+
7+
**For Local Development:**
8+
9+
* [Docker Desktop](https://www.docker.com/products/docker-desktop/) or any other compatible container runtime (e.g., Podman, OrbStack) installed.
10+
* [Visual Studio Code](https://code.visualstudio.com/) with the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed.
11+
12+
**For GitHub Codespaces:**
13+
14+
* A GitHub account.
15+
16+
### Starting Dev Container
17+
18+
**Using Visual Studio Code (Local):**
19+
20+
1. Clone the repository.
21+
2. Open the repository in Visual Studio Code.
22+
3. Open the command palette in Visual Studio Code (`Ctrl + Shift + P` or `Cmd + Shift + P`) and execute `Dev Containers: Reopen in Container`.
23+
24+
**Using GitHub Codespaces (Cloud):**
25+
26+
1. Navigate to the repository on GitHub.
27+
2. Click the "<> Code" button.
28+
3. Select the "Codespaces" tab.
29+
4. Click "Create codespace on main" (or your desired branch).
30+
31+
### Dev Container Configuration
32+
33+
Dev Container settings are configured in `.devcontainer/devcontainer.json`. In this file, you can set the Docker image to use, extensions to install, port forwarding, and more. This configuration is used both for local development and GitHub Codespaces.
34+
35+
### Development
36+
37+
Once the Dev Container is started, you can proceed with development as usual. The container already has the necessary tools and libraries installed. In GitHub Codespaces, you will have a fully configured VS Code in your browser or desktop application.
38+
39+
### Stopping Dev Container
40+
41+
**Using Visual Studio Code (Local):**
42+
43+
To stop the Dev Container, open the command palette in Visual Studio Code and execute `Remote: Close Remote Connection`.
44+
45+
**Using GitHub Codespaces (Cloud):**
46+
47+
GitHub Codespaces will automatically stop after a period of inactivity. You can also manually stop the codespace from the Codespaces menu in GitHub.
48+
49+
### More Information
50+
51+
* [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/remote/containers)
52+
* [Dev Container Specification](https://containers.dev/implementors/json_reference/)
53+
* [GitHub Codespaces](https://github.com/features/codespaces)
54+
55+
This document describes the basic usage of Dev Container and GitHub Codespaces. Add project-specific settings and procedures as needed.

0 commit comments

Comments
 (0)