Skip to content

Commit b5ed43a

Browse files
Copilot0xrinegade
andcommitted
Add GitHub Copilot environment preinstallation with devcontainer setup
- Enhanced .github/copilot-instructions.md with preinstallation options - Created .devcontainer/devcontainer.json with Rust + Node.js base image - Added .devcontainer/setup.sh script for automated environment setup - Included comprehensive documentation for devcontainer usage - Added benefits section explaining advantages of preinstalled environments - Updated repository structure to reflect new devcontainer directory Addresses user feedback about GitHub's Copilot environment customization capabilities. Co-authored-by: 0xrinegade <[email protected]>
1 parent 93ae40c commit b5ed43a

File tree

4 files changed

+238
-1
lines changed

4 files changed

+238
-1
lines changed

.devcontainer/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Development Container for OpenSVM P2P Exchange
2+
3+
This directory contains the development container configuration for the OpenSVM P2P Exchange project, providing a fully configured environment with all necessary tools preinstalled.
4+
5+
## What's Included
6+
7+
The development container automatically installs and configures:
8+
9+
- **Rust toolchain** with latest stable version
10+
- **Node.js 18** with npm and build tools
11+
- **Anchor 0.31.1** via Anchor Version Manager (AVM)
12+
- **System dependencies** for Solana development (libudev-dev, libssl-dev, etc.)
13+
- **VS Code extensions** for Rust, TypeScript, and Tailwind CSS development
14+
- **Project dependencies** via `npm install --legacy-peer-deps`
15+
16+
## Usage
17+
18+
### With GitHub Codespaces
19+
1. Navigate to the repository on GitHub
20+
2. Click "Code" → "Create codespace on main"
21+
3. Wait ~3-5 minutes for automatic setup to complete
22+
4. Start developing immediately with `npm run dev`
23+
24+
### With VS Code
25+
1. Install the "Dev Containers" extension
26+
2. Open the project in VS Code
27+
3. Command palette: "Dev Containers: Reopen in Container"
28+
4. Wait for setup to complete
29+
5. Start developing with `npm run dev`
30+
31+
### With GitHub Copilot
32+
The development container is automatically detected and used by GitHub Copilot coding agents, providing immediate access to a fully configured environment.
33+
34+
## Configuration Files
35+
36+
- `devcontainer.json`: Main configuration with base image, features, and VS Code settings
37+
- `setup.sh`: Post-creation script that installs project-specific tools and dependencies
38+
39+
## Ports
40+
41+
The container forwards these ports for development:
42+
- `3000`: Next.js development server
43+
- `8899`: Solana local validator (if used)
44+
45+
## Troubleshooting
46+
47+
If setup fails:
48+
1. Check the terminal output during container creation
49+
2. Manually run `.devcontainer/setup.sh` to see detailed error messages
50+
3. Ensure Docker/Podman is running and has sufficient resources (4GB+ RAM recommended)
51+
52+
## Manual Setup Alternative
53+
54+
If you cannot use the development container, refer to the manual setup instructions in `.github/copilot-instructions.md`.

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "OpenSVM P2P Exchange",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1-bullseye",
4+
"features": {
5+
"ghcr.io/devcontainers/features/node:1": {
6+
"version": "18",
7+
"nodeGypDependencies": true
8+
},
9+
"ghcr.io/devcontainers/features/common-utils:2": {
10+
"installZsh": true,
11+
"installOhMyZsh": true,
12+
"upgradePackages": true
13+
}
14+
},
15+
"postCreateCommand": "bash .devcontainer/setup.sh",
16+
"customizations": {
17+
"vscode": {
18+
"extensions": [
19+
"rust-lang.rust-analyzer",
20+
"ms-vscode.vscode-typescript-next",
21+
"bradlc.vscode-tailwindcss",
22+
"esbenp.prettier-vscode",
23+
"ms-vscode.vscode-eslint",
24+
"GitHub.copilot"
25+
]
26+
}
27+
},
28+
"forwardPorts": [3000, 8899],
29+
"remoteUser": "vscode"
30+
}

.devcontainer/setup.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🚀 Setting up OpenSVM P2P Exchange development environment..."
5+
6+
# Install system dependencies required for Solana/Anchor development
7+
echo "📦 Installing system dependencies..."
8+
sudo apt-get update && sudo apt-get install -y \
9+
libudev-dev \
10+
libssl-dev \
11+
pkg-config \
12+
build-essential \
13+
curl \
14+
wget \
15+
git
16+
17+
# Install Anchor Version Manager
18+
echo "⚓ Installing Anchor Version Manager..."
19+
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
20+
21+
# Add AVM to PATH
22+
echo 'export PATH="$HOME/.avm/bin:$PATH"' >> ~/.bashrc
23+
export PATH="$HOME/.avm/bin:$PATH"
24+
25+
# Install and use Anchor 0.31.1
26+
echo "📦 Installing Anchor 0.31.1..."
27+
avm install 0.31.1
28+
avm use 0.31.1
29+
30+
# Verify Anchor installation
31+
echo "✅ Verifying Anchor installation..."
32+
anchor --version
33+
34+
# Install Node.js dependencies with legacy peer deps flag
35+
echo "📦 Installing Node.js dependencies..."
36+
npm install --legacy-peer-deps
37+
38+
# Verify Node.js setup
39+
echo "✅ Verifying Node.js setup..."
40+
node --version
41+
npm --version
42+
43+
# Build the project to verify everything is working
44+
echo "🔨 Building project to verify setup..."
45+
npm run build
46+
47+
echo ""
48+
echo "✅ Development environment setup complete!"
49+
echo "📝 You can now use:"
50+
echo " npm run dev - Start development server"
51+
echo " npm run build - Build for production"
52+
echo " npm test - Run tests"
53+
echo " anchor build - Build Solana programs"
54+
echo ""

.github/copilot-instructions.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,105 @@ OpenSVM P2P Exchange is a Next.js-based Progressive Web App (PWA) for peer-to-pe
44

55
**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
66

7+
## Environment Preinstallation
8+
9+
For optimal Copilot agent performance, consider setting up preinstalled tools in your development environment using one of these approaches:
10+
11+
### Option 1: Development Container (Recommended)
12+
Create `.devcontainer/devcontainer.json` to preinstall all dependencies:
13+
14+
```json
15+
{
16+
"name": "OpenSVM P2P Exchange",
17+
"image": "mcr.microsoft.com/devcontainers/rust:1-bullseye",
18+
"features": {
19+
"ghcr.io/devcontainers/features/node:1": {
20+
"version": "18",
21+
"nodeGypDependencies": true
22+
},
23+
"ghcr.io/devcontainers/features/common-utils:2": {
24+
"installZsh": true,
25+
"installOhMyZsh": true,
26+
"upgradePackages": true
27+
}
28+
},
29+
"postCreateCommand": "bash .devcontainer/setup.sh",
30+
"customizations": {
31+
"vscode": {
32+
"extensions": [
33+
"rust-lang.rust-analyzer",
34+
"ms-vscode.vscode-typescript-next",
35+
"bradlc.vscode-tailwindcss"
36+
]
37+
}
38+
},
39+
"forwardPorts": [3000, 8899]
40+
}
41+
```
42+
43+
Create `.devcontainer/setup.sh`:
44+
```bash
45+
#!/bin/bash
46+
set -e
47+
48+
# Install system dependencies
49+
sudo apt-get update && sudo apt-get install -y libudev-dev libssl-dev pkg-config build-essential
50+
51+
# Install Anchor Version Manager
52+
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
53+
echo 'export PATH="$HOME/.avm/bin:$PATH"' >> ~/.bashrc
54+
source ~/.bashrc
55+
56+
# Install and use Anchor 0.31.1
57+
avm install 0.31.1 && avm use 0.31.1
58+
59+
# Install Node.js dependencies
60+
npm install --legacy-peer-deps
61+
62+
echo "✅ Development environment setup complete!"
63+
```
64+
65+
### Option 2: GitHub Codespaces Configuration
66+
Create `.devcontainer/devcontainer.json` for Codespaces with preinstalled tools:
67+
68+
```json
69+
{
70+
"name": "OpenSVM P2P Exchange Codespace",
71+
"image": "mcr.microsoft.com/devcontainers/javascript-node:18-bullseye",
72+
"features": {
73+
"ghcr.io/devcontainers/features/rust:1": {},
74+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
75+
},
76+
"postCreateCommand": "bash .devcontainer/setup-codespaces.sh",
77+
"remoteUser": "node"
78+
}
79+
```
80+
81+
### Option 3: Manual Environment Setup
82+
If devcontainer is not available, follow the manual steps below, but expect longer setup times.
83+
84+
### Benefits of Preinstallation
85+
Using preinstalled environments provides several advantages:
86+
- **Faster agent startup**: No need to install Rust, Anchor, or system dependencies
87+
- **Consistent environment**: Same setup across all development sessions
88+
- **Reduced timeout risks**: Eliminates long-running installation commands
89+
- **Better reliability**: Pre-validated tool versions and configurations
90+
- **Immediate productivity**: Agent can start working on code immediately
91+
92+
### Using the Development Container
93+
To use the preinstalled environment:
94+
95+
1. **With GitHub Codespaces**: Click "Code" → "Create codespace" (environment auto-configures)
96+
2. **With VS Code**: Install "Dev Containers" extension, then "Reopen in Container"
97+
3. **With GitHub Copilot**: The devcontainer will be automatically detected and used
98+
99+
The setup script runs automatically and takes ~3-5 minutes to complete all installations.
100+
7101
## Working Effectively
8102

9-
### Prerequisites and System Setup
103+
### Prerequisites and System Setup (Manual Fallback)
104+
**Use this section only if preinstallation options above are not available.**
105+
10106
**Install required system dependencies first:**
11107
```bash
12108
sudo apt-get update && sudo apt-get install -y libudev-dev libssl-dev pkg-config build-essential
@@ -141,6 +237,9 @@ npm run build && npm run start
141237
├── package.json # Dependencies and scripts
142238
├── next.config.js # Next.js PWA configuration
143239
├── Anchor.toml # Solana program configuration
240+
├── .devcontainer/ # Development container setup
241+
│ ├── devcontainer.json # VS Code devcontainer config
242+
│ └── setup.sh # Environment setup script
144243
├── programs/p2p-exchange/ # Rust smart contracts
145244
├── src/ # React frontend source
146245
├── public/ # Static assets

0 commit comments

Comments
 (0)