forked from microsoft/PyRIT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevcontainer_setup.sh
More file actions
68 lines (52 loc) · 2.29 KB
/
Copy pathdevcontainer_setup.sh
File metadata and controls
68 lines (52 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -e
VIRTUAL_ENV="/opt/venv"
# cleanup old extensions
sudo rm -rf /vscode/vscode-server/extensionsCache/github.copilot-*
rm -rf /home/vscode/.vscode-server/extensions/{*,.[!.]*,..?*}
# Activate the uv venv created in the Dockerfile
source /opt/venv/bin/activate
# Store hash inside venv so it's tied to the venv lifecycle
HASH_FILE="/opt/venv/pyproject_hash"
# Compute current hash
CURRENT_HASH=$(sha256sum /workspace/pyproject.toml | awk '{print $1}')
# Check if hash file exists and if the hash has changed
if [ ! -f "$HASH_FILE" ] || [ "$(cat $HASH_FILE)" != "$CURRENT_HASH" ]; then
echo "📦 pyproject.toml has changed, installing environment..."
# Install dependencies
uv pip install ipykernel
uv pip install -e ".[dev,all]"
# Register the kernel with Jupyter
python -m ipykernel install --user --name=pyrit-dev --display-name="Python (pyrit-dev)"
# Save the new hash
echo "$CURRENT_HASH" > "$HASH_FILE"
else
echo "✅ pyproject.toml has not changed, skipping installation."
fi
# Install frontend dependencies
echo "📦 Installing frontend dependencies..."
# Fix node_modules permissions (volume is owned by root)
if [ -d "/workspace/frontend/node_modules" ]; then
echo "Fixing node_modules permissions..."
sudo chown -R vscode:vscode /workspace/frontend/node_modules
fi
cd /workspace/frontend
if [ -f "package.json" ]; then
npm install
# Install Playwright browsers and system dependencies for E2E testing
# This may fail if apt repos have signature issues - don't block setup
echo "📦 Installing Playwright browsers..."
# Remove third-party repos with SHA1 signature issues (rejected since 2026-02-01)
# Playwright deps come from Debian main repos, these aren't needed
sudo rm -f /etc/apt/sources.list.d/yarn.list \
/etc/apt/sources.list.d/nodesource.list \
/etc/apt/sources.list.d/microsoft.list 2>/dev/null || true
if npx playwright install --with-deps chromium; then
echo "✅ Playwright browsers installed."
else
echo "⚠️ Playwright installation failed (apt signature issues). Run 'npx playwright install chromium' manually if needed for E2E tests."
fi
echo "✅ Frontend dependencies installed."
fi
cd /workspace
echo "🚀 Dev container setup complete!"