Skip to content

Commit f2856d4

Browse files
committed
feat: add justfile for building and testing ai-container devcontainers
Signed-off-by: Aaron Wislang <aaron.wislang@microsoft.com>
1 parent e4a9935 commit f2856d4

File tree

2 files changed

+223
-0
lines changed

2 files changed

+223
-0
lines changed

docs/build.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Build Documentation
2+
3+
This project uses [just](https://github.com/casey/just) as a command runner to simplify common development tasks.
4+
5+
## Installing Just
6+
7+
### Via Cargo (Recommended)
8+
9+
If you have Rust installed, you can install `just` using cargo:
10+
11+
```bash
12+
cargo install just
13+
```
14+
15+
### Other Installation Methods
16+
17+
- **macOS (Homebrew)**: `brew install just`
18+
- **Ubuntu/Debian**: `sudo apt install just`
19+
- **Arch Linux**: `pacman -S just`
20+
- **Windows (Scoop)**: `scoop install just`
21+
- **Windows (Chocolatey)**: `choco install just`
22+
23+
For more installation options, see the [just installation guide](https://github.com/casey/just#installation).
24+
25+
## Available Commands
26+
27+
Run `just` or `just --list` to see all available commands:
28+
29+
```bash
30+
just --list
31+
```
32+
33+
### Container Commands
34+
35+
#### `just build-ai-container [tag="latest"]`
36+
Builds the ai-container devcontainer locally with the specified tag.
37+
38+
```bash
39+
# Build with default tag (latest)
40+
just build-ai-container
41+
42+
# Build with custom tag
43+
just build-ai-container v1.0.0
44+
```
45+
46+
#### `just test-ai-container [tag="latest"]`
47+
Runs the ai-container interactively for testing purposes.
48+
49+
```bash
50+
just test-ai-container
51+
```
52+
53+
#### `just run-ai-container [tag="latest"]`
54+
Starts the ai-container as a background service (similar to how VS Code would run it).
55+
56+
```bash
57+
just run-ai-container
58+
```
59+
60+
#### `just stop-ai-container`
61+
Stops and removes the background ai-container service.
62+
63+
```bash
64+
just stop-ai-container
65+
```
66+
67+
### Development Workflow Commands
68+
69+
#### `just build-and-test-ai [tag="latest"]`
70+
Builds and then tests the ai-container in one command.
71+
72+
```bash
73+
just build-and-test-ai
74+
```
75+
76+
#### `just test-tools [tag="latest"]`
77+
Tests all the installed tools inside the container to verify they're working correctly.
78+
79+
```bash
80+
just test-tools
81+
```
82+
83+
This will test:
84+
- Go version
85+
- Rust version (rustc and cargo)
86+
- Node.js and npm versions
87+
- Azure CLI
88+
- GitHub CLI
89+
- Wassette
90+
- NPM global packages
91+
92+
### Cleanup Commands
93+
94+
#### `just clean`
95+
Cleans up Docker images and containers related to the project.
96+
97+
```bash
98+
just clean
99+
```
100+
101+
## Example Workflow
102+
103+
Here's a typical development workflow using just:
104+
105+
1. **Build the container:**
106+
```bash
107+
just build-ai-container
108+
```
109+
110+
2. **Test that all tools work:**
111+
```bash
112+
just test-tools
113+
```
114+
115+
3. **Run interactive testing:**
116+
```bash
117+
just test-ai-container
118+
```
119+
120+
4. **Clean up when done:**
121+
```bash
122+
just clean
123+
```
124+
125+
## Justfile Location
126+
127+
The justfile is located in the root of the repository and contains all the command definitions. You can examine it to see exactly what each command does or to add your own custom commands.

justfile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# justfile for building and testing devcontainers locally
2+
3+
# Default recipe - show available commands
4+
default:
5+
@just --list
6+
7+
# Build the ai-container devcontainer locally
8+
build-ai-container tag="latest":
9+
#!/usr/bin/env bash
10+
echo "Building ai-container devcontainer..."
11+
if docker build \
12+
-t codespaces-ai:{{tag}} \
13+
-t ghcr.io/asw101/codespaces/ai:{{tag}} \
14+
.devcontainer/ai-container/; then
15+
echo "✅ Built ai-container as codespaces-ai:{{tag}}"
16+
else
17+
echo "❌ Build failed for ai-container"
18+
exit 1
19+
fi
20+
21+
# Run the ai-container interactively for testing
22+
test-ai-container tag="latest":
23+
#!/usr/bin/env bash
24+
echo "Starting ai-container for testing..."
25+
docker run -it --rm \
26+
-v $(pwd):/workspace \
27+
-w /workspace \
28+
--name test-ai-container \
29+
codespaces-ai:{{tag}} \
30+
bash
31+
32+
# Run the ai-container as a background service (like VS Code would)
33+
run-ai-container tag="latest":
34+
#!/usr/bin/env bash
35+
echo "Starting ai-container in background..."
36+
docker run -d \
37+
-v $(pwd):/workspace \
38+
-w /workspace \
39+
-p 8080:8080 \
40+
--name ai-container-service \
41+
codespaces-ai:{{tag}} \
42+
tail -f /dev/null
43+
echo "✅ ai-container running as 'ai-container-service'"
44+
echo "Use 'just exec-ai-container' to get a shell"
45+
46+
# Stop the background ai-container service
47+
stop-ai-container:
48+
#!/usr/bin/env bash
49+
echo "Stopping ai-container service..."
50+
docker stop ai-container-service || true
51+
docker rm ai-container-service || true
52+
echo "✅ ai-container service stopped"
53+
54+
# Build and test ai-container in one command
55+
build-and-test-ai tag="latest":
56+
just build-ai-container {{tag}}
57+
just test-ai-container {{tag}}
58+
59+
# Clean up Docker images and containers
60+
clean:
61+
#!/usr/bin/env bash
62+
echo "Cleaning up Docker resources..."
63+
docker stop ai-container-service 2>/dev/null || true
64+
docker rm ai-container-service 2>/dev/null || true
65+
docker rmi codespaces-ai:latest 2>/dev/null || true
66+
docker rmi ghcr.io/asw101/codespaces/ai:latest 2>/dev/null || true
67+
echo "✅ Cleanup complete"
68+
69+
# Test specific tools inside the container
70+
test-tools tag="latest":
71+
#!/usr/bin/env bash
72+
echo "Testing tools in ai-container..."
73+
docker run --rm codespaces-ai:{{tag}} bash -c "
74+
echo '=== Go version ==='
75+
go version
76+
echo
77+
echo '=== Rust version ==='
78+
rustc --version
79+
cargo --version
80+
echo
81+
echo '=== Node.js version ==='
82+
node --version
83+
npm --version
84+
echo
85+
echo '=== Azure CLI ==='
86+
az --version | head -1
87+
echo
88+
echo '=== GitHub CLI ==='
89+
gh --version
90+
echo
91+
echo '=== Wassette ==='
92+
wassette --version
93+
echo
94+
echo '=== NPM global packages ==='
95+
npm list -g --depth=0
96+
"

0 commit comments

Comments
 (0)