Skip to content

Commit d07c81a

Browse files
Add Claude Code support (#30)
* Add Claude Code support for dev container Configures Claude Code to use AWS Bedrock for model access inside dev container. Instructions for getting started with Claude are added to the README. * Move AWS keys to ~/.aws/credentials in container Allows user to update AWS keys without rebuilding the dev container * Update README * retain claude history across rebuilds (#32) --------- Co-authored-by: Andrew Schlackman <72105194+sei-aschlackman@users.noreply.github.com>
1 parent bb04e88 commit d07c81a

File tree

8 files changed

+201
-3
lines changed

8 files changed

+201
-3
lines changed

.claude/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore local Claude Code settings
2+
settings.local.json

.claude/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"permissions": {
3+
"additionalDirectories": [
4+
"/mnt/data/crucible"
5+
]
6+
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[default]
2+
aws_access_key_id = <AWS Access Key for Bedrock>
3+
aws_secret_access_key = <AWS Secret Key for Bedrock>

.devcontainer/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.aws/credentials

.devcontainer/devcontainer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,26 @@
2121
"ghcr.io/devcontainers/features/github-cli:1": {},
2222
"ghcr.io/devcontainers/features/php:1": {
2323
"version": "8.3"
24-
}
24+
},
25+
"ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
2526
},
2627
"containerEnv": {
27-
"NUGET_PACKAGES": "/home/vscode/.nuget/packages" // this might not be needed. will try removing later.
28+
"NUGET_PACKAGES": "/home/vscode/.nuget/packages", // this might not be needed. will try removing later.
29+
"CLAUDE_CODE_USE_BEDROCK": "1", // vars for Claude Code using Amazon Bedrock
30+
"AWS_REGION": "us-east-1",
31+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "us.anthropic.claude-haiku-4-5-20251001-v1:0"
2832
},
2933
"mounts": [
3034
// crucible repo data
3135
"source=crucible-dev-data,target=/mnt/data/,type=volume",
3236
// Usersecrets
3337
"source=crucible-dev-microsoft,target=/home/vscode/.microsoft,type=volume",
3438
// Shell history
35-
"source=crucible-dev-shell-history,target=/home/vscode/.history,type=volume"
39+
"source=crucible-dev-shell-history,target=/home/vscode/.history,type=volume",
40+
// AWS credentials for Claude Code (optional)
41+
"source=${localWorkspaceFolder}/.devcontainer/.aws,target=/home/vscode/.aws,type=bind,readonly",
42+
// Claude Code History
43+
"source=crucible-dev-claude-history,target=/home/vscode/.claude/projects/-workspaces-crucible-development,type=volume"
3644
],
3745
"postCreateCommand": "bash -l .devcontainer/postcreate.sh",
3846
"postStartCommand": "bash -l .devcontainer/poststart.sh",

.devcontainer/postcreate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ git config devcontainers-theme.show-dirty 1
55

66
sudo chown -R $(whoami): /home/vscode/.microsoft
77
sudo chown -R $(whoami): /mnt/data/
8+
sudo chown -R $(whoami): /home/vscode/.claude
89

910
scripts/clone-repos.sh
1011
scripts/add-moodle-mounts.sh

CLAUDE.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Crucible Development is a Development Container and .NET Aspire orchestration environment for the Crucible platform - a cybersecurity training and simulation platform developed by Carnegie Mellon University's Software Engineering Institute (SEI).
8+
9+
This is a **meta-repository** that orchestrates 30+ external repositories cloned into `/mnt/data/crucible/`. The main orchestrator (`Crucible.AppHost`) manages all microservices using .NET Aspire.
10+
11+
## Architecture
12+
13+
### Core Components
14+
- **Crucible.AppHost** - Central .NET Aspire orchestrator that manages all services
15+
- **PostgreSQL** - Centralized multi-tenant database (container: `crucible-postgres`)
16+
- **Keycloak** - OpenID Connect identity provider (ports 8080/8443)
17+
- **MkDocs** - Documentation server (port 8000)
18+
- **PGAdmin** - Database admin UI (port 33000)
19+
20+
### Microservices (in `/mnt/data/crucible/`)
21+
| Service | Purpose | Ports |
22+
|---------|---------|-------|
23+
| Player API/UI | Main learning platform | 4301 |
24+
| Player VM API/UI | Virtual machine management | 4303 |
25+
| Console UI | Console access | 4305 |
26+
| Caster API/UI | Infrastructure orchestration | 4310 |
27+
| Alloy API/UI | Advanced orchestration | 4403 |
28+
| TopoMojo API/UI | Network topology simulation | 5000/4201 |
29+
| Steamfitter API/UI | Scenario execution | 4401 |
30+
| CITE API/UI | Collaborative training | 4721 |
31+
| Gallery API/UI | Content management | 4723 |
32+
| Blueprint API/UI | Scenario design | 4725 |
33+
| Gameboard API/UI | Competition/scoring | 4202 |
34+
| Moodle | LMS integration | 8081 |
35+
| LRsql | Learning Record Store (xAPI) | 9274 |
36+
37+
### Service Configuration
38+
Services are controlled via environment files in `.env/` directory and `LaunchOptions` class. Environment files use `Launch__<ServiceName>=true/false` pattern (e.g., `Launch__Player=true`). Each service can be individually toggled without rebuilding.
39+
40+
## Common Commands
41+
42+
### Building
43+
```bash
44+
dotnet build Crucible.slnx
45+
dotnet publish Crucible.slnx
46+
```
47+
48+
### Running Services
49+
Use VS Code's Run and Debug panel with launch configurations. Each configuration uses a corresponding `.env/<name>.env` file:
50+
- **Default** - All default services (excluding Moodle/LRsql)
51+
- **Exercise**, **TTX** - Specific service combinations
52+
- **Service-specific** - Player, Caster, Alloy, TopoMojo, Steamfitter, CITE, Gallery, Blueprint, Gameboard
53+
- **Moodle** - Runs Moodle without xdebug
54+
- **Moodle Debug** - Compound task that runs Moodle with xdebug enabled (starts both Moodle-Xdebug and Xdebug configurations)
55+
- **Lrsql** - Runs Learning Record Store
56+
57+
### Database Operations
58+
```bash
59+
# Seed/restore database (example: blueprint)
60+
docker cp blueprint.dump crucible-postgres:/tmp/blueprint.dump
61+
docker exec -it crucible-postgres /bin/bash
62+
/usr/lib/postgresql/17/bin/psql --username=postgres blueprint < /tmp/blueprint.dump
63+
64+
# Backup database
65+
docker exec -it crucible-postgres /bin/bash
66+
pg_dump -U postgres blueprint > /tmp/blueprint.dump
67+
exit
68+
docker cp crucible-postgres:/tmp/blueprint.dump blueprint.dump
69+
```
70+
71+
### Global Tools
72+
```bash
73+
dotnet tool install -g Aspire.Cli
74+
dotnet tool install --global dotnet-ef --version 10
75+
npm install -g @angular/cli@latest
76+
```
77+
78+
## Development Patterns
79+
80+
### Adding New Services
81+
1. Add repository to `scripts/repos.json`
82+
2. Update `Crucible.AppHost/AppHost.cs` with service registration
83+
3. Add launch configuration to `.vscode/launch.json`
84+
4. Create environment file in `.env/` directory
85+
86+
### Adding Moodle Plugins
87+
1. Add repository to `scripts/repos.json`
88+
2. Update `.vscode/launch.json` (add path mappings for xdebug)
89+
3. Update `Crucible.AppHost/AppHost.cs` (add bind mounts)
90+
4. Update `scripts/xdebug_filter.sh`
91+
5. For additional paths: also update `Dockerfile.MoodleCustom`, `add-moodle-mounts.sh`, `pre_configure.sh`
92+
93+
### Service Dependencies Pattern
94+
All services follow this pattern in `AppHost.cs`:
95+
- `.WaitFor(postgres)` - Wait for database
96+
- `.WaitFor(keycloak)` - Wait for identity provider
97+
- `.WithReference(db, "PostgreSQL")` - Database connection
98+
- `.WithExplicitStart()` - Service won't auto-start
99+
100+
## Key Files
101+
102+
- `Crucible.AppHost/AppHost.cs` - Main service orchestration logic
103+
- `Crucible.AppHost/LaunchOptions.cs` - Service toggle options
104+
- `Crucible.slnx` - Solution file including external projects
105+
- `scripts/repos.json` - List of repositories to clone
106+
- `scripts/clone-repos.sh` - Repository cloning script
107+
- `.env/*.env` - Environment configurations for different launch profiles
108+
- `Crucible.AppHost/resources/` - UI configuration files and Keycloak realm
109+
110+
## Requirements
111+
112+
### License Headers
113+
All source files require MIT (SEI)-style copyright headers. Enforced by GitHub Actions on PRs.
114+
115+
```csharp
116+
// Copyright 2025 Carnegie Mellon University. All Rights Reserved.
117+
// Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.
118+
```
119+
120+
### Docker Resources
121+
- Memory: 16GB minimum
122+
- Disk: 120GB minimum
123+
124+
### Custom Certificates
125+
For corporate proxy environments (Zscaler), place certificates in `.devcontainer/certs/`. See `.devcontainer/certs/README.md`.
126+
127+
## Moodle Development
128+
129+
### OAuth Setup
130+
After first Moodle start:
131+
1. Login with oauth admin user to create account in Moodle
132+
2. Make oauth admin a site admin (either via local admin UI or restart Moodle container - it auto-adds oauth admin on restart)
133+
3. Login as oauth admin, go to Site Administration > Server > OAuth server settings and connect the system account
134+
135+
### Xdebug
136+
- Control xdebug mode via `Launch__XdebugMode` in env files (values: `off`, `debug`, `coverage`, etc.)
137+
- **Warning**: PHP will pause execution after "Upgrading config.php..." if xdebug is enabled but VS Code debugger isn't running
138+
- Xdebug listens on port 9003; ensure the Xdebug launch config is running before starting Moodle with xdebug enabled
139+
- Debug display in browser: use `tool_userdebug` plugin icon (left of user avatar)
140+
141+
### Plugin Configuration
142+
- **Crucible Plugin**: Requires oauth configured, service account connected, and user logged in via oauth
143+
- **TopoMojo Plugin**: Generate API key in TopoMojo UI and add to Moodle plugin config or `post_configure.sh`
144+
- **Additional Official Plugins**: Add to `PLUGINS` environment variable in `AppHost.cs`
145+
146+
## Troubleshooting
147+
148+
- **Aspire resources exit with no log**: Run `docker ps -a` to see stopped containers and error codes
149+
- **npm install issues on ARM**: May need additional OS packages; run `npm i` manually to see errors
150+
- **C# extension fails in container**: Reinstall extensions listed in `devcontainer.json`

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ The dev container is designed to work with Zscaler. You will need to copy the re
2727

2828
For details on how to add root CA certificates (including Zscaler and any development CAs), see the [Custom Certs Docs](.devcontainer/certs/README.md).
2929

30+
## Claude Code
31+
32+
The dev container includes [Claude Code](https://docs.anthropic.com/en/docs/claude-code), Anthropic's CLI for Claude, configured to use AWS Bedrock via the official [Claude Code devcontainer feature](https://github.com/anthropics/devcontainer-features).
33+
34+
### Setup
35+
36+
1. Copy the example credentials file:
37+
```bash
38+
cp .devcontainer/.aws/credentials.example .devcontainer/.aws/credentials
39+
```
40+
41+
2. Edit `.devcontainer/.aws/credentials` and add your AWS credentials:
42+
```ini
43+
[default]
44+
aws_access_key_id = <AWS Access Key for Bedrock>
45+
aws_secret_access_key = <AWS Secret Key for Bedrock>
46+
```
47+
48+
3. Build or rebuild the dev container
49+
50+
The credentials file is mounted to `/home/vscode/.aws/credentials` inside the container and is excluded from git via `.devcontainer/.gitignore`.
51+
52+
### Usage
53+
54+
Once the container is running with valid credentials, run `claude` in the terminal to start Claude Code.
55+
3056
## Troubleshooting
3157

3258
This repo is still under construction, so you may run into the occasional challenge or oddity. From our lessons learned:

0 commit comments

Comments
 (0)