Skip to content

Adopt Devcontainer for Development Environment #81

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

Merged
merged 4 commits into from
Apr 2, 2025
Merged
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
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.10",
"toolsToInstall": "uv"
}
},
// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
}
}
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "uv venv"
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
// "mounts": [
// {
// "source": "devcontainer-cargo-cache-${devcontainerId}",
// "target": "/usr/local/cargo",
// "type": "volume"
// }
// ]
// 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": [],
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,7 @@ See [examples](examples/README.md)

- [MCP Specification](https://spec.modelcontextprotocol.io/specification/2024-11-05/)
- [Schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts)

## Development with Dev Container

See [docs/DEVCONTAINER.md](docs/DEVCONTAINER.md) for instructions on using Dev Container for development.
Comment on lines +192 to +194
Copy link
Contributor Author

@Z9RTM Z9RTM Apr 2, 2025

Choose a reason for hiding this comment

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

Hi @jokemanfire, I've created a dedicated document for Dev Container setup in docs/DEVCONTAINER.md as we discussed. I've also added a link to it in the README.md. Could you please take a look and let me know if you have any feedback?

Copy link
Collaborator

Choose a reason for hiding this comment

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

thks , and pls add a link in root's readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your feedback.
The link to the Dev Container documentation has already been added to the project root's README.md, under the "Development with Dev Container" section.

Please take a look at it here: https://github.com/Z9RTM/rust-sdk/tree/devcontainer?tab=readme-ov-file#development-with-dev-container

If you still can't find it or have any further questions, please let me know.

55 changes: 55 additions & 0 deletions docs/DEVCONTAINER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## Development with Dev Container and GitHub Codespaces

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.

### Prerequisites

**For Local Development:**

* [Docker Desktop](https://www.docker.com/products/docker-desktop/) or any other compatible container runtime (e.g., Podman, OrbStack) installed.
* [Visual Studio Code](https://code.visualstudio.com/) with the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed.

**For GitHub Codespaces:**

* A GitHub account.

### Starting Dev Container

**Using Visual Studio Code (Local):**

1. Clone the repository.
2. Open the repository in Visual Studio Code.
3. Open the command palette in Visual Studio Code (`Ctrl + Shift + P` or `Cmd + Shift + P`) and execute `Dev Containers: Reopen in Container`.

**Using GitHub Codespaces (Cloud):**

1. Navigate to the repository on GitHub.
2. Click the "<> Code" button.
3. Select the "Codespaces" tab.
4. Click "Create codespace on main" (or your desired branch).

### Dev Container Configuration

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.

### Development

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.

### Stopping Dev Container

**Using Visual Studio Code (Local):**

To stop the Dev Container, open the command palette in Visual Studio Code and execute `Remote: Close Remote Connection`.

**Using GitHub Codespaces (Cloud):**

GitHub Codespaces will automatically stop after a period of inactivity. You can also manually stop the codespace from the Codespaces menu in GitHub.

### More Information

* [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/remote/containers)
* [Dev Container Specification](https://containers.dev/implementors/json_reference/)
* [GitHub Codespaces](https://github.com/features/codespaces)

This document describes the basic usage of Dev Container and GitHub Codespaces. Add project-specific settings and procedures as needed.
Loading