Skip to content

Commit bba91f2

Browse files
author
Marvin Zhang
committed
feat: Add VSCode Automation Docker environment for GitHub Copilot testing
- Create Dockerfile for a VSCode automation environment based on Ubuntu 22.04 - Install necessary system dependencies and VS Code Insiders with GitHub Copilot extensions - Set up code-server for web access and VNC for remote desktop - Implement entrypoint script to manage services and automation tests - Add automation configuration and test scenarios for Python, JavaScript, and TypeScript - Include README documentation for setup and usage instructions - Remove unused devlog creation components and related navigation links - Update dashboard and devlog list components to streamline UI and interactions
1 parent cee3dfa commit bba91f2

File tree

18 files changed

+1347
-235
lines changed

18 files changed

+1347
-235
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/bin/bash
2+
# Build VSCode Automation Docker Image
3+
set -euo pipefail
4+
5+
# Configuration
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
8+
IMAGE_NAME="codervisor/devlog-vscode-automation"
9+
DOCKERFILE="Dockerfile.vscode-automation"
10+
11+
# Function to log messages
12+
log() {
13+
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*"
14+
}
15+
16+
# Check if Docker is available
17+
check_docker() {
18+
if ! command -v docker &> /dev/null; then
19+
log "ERROR: Docker is not installed or not in PATH"
20+
exit 1
21+
fi
22+
23+
if ! docker info &> /dev/null; then
24+
log "ERROR: Docker daemon is not running"
25+
exit 1
26+
fi
27+
}
28+
29+
# Build the Docker image
30+
build_image() {
31+
local tag="${1:-latest}"
32+
33+
log "Building VSCode automation Docker image..."
34+
log "Image: $IMAGE_NAME:$tag"
35+
log "Dockerfile: $DOCKERFILE"
36+
log "Context: $PROJECT_ROOT"
37+
38+
# Ensure AI package is built first
39+
if [ ! -d "$PROJECT_ROOT/packages/ai/build" ]; then
40+
log "Building AI package first..."
41+
cd "$PROJECT_ROOT"
42+
pnpm --filter @codervisor/devlog-ai build
43+
fi
44+
45+
# Build the Docker image
46+
docker build \
47+
-f "$PROJECT_ROOT/$DOCKERFILE" \
48+
-t "$IMAGE_NAME:$tag" \
49+
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
50+
--build-arg VCS_REF="$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')" \
51+
"$PROJECT_ROOT"
52+
53+
if [ $? -eq 0 ]; then
54+
log "✅ Successfully built $IMAGE_NAME:$tag"
55+
56+
# Show image info
57+
docker images "$IMAGE_NAME:$tag"
58+
59+
# Show image size
60+
local size=$(docker images --format "table {{.Size}}" "$IMAGE_NAME:$tag" | tail -n 1)
61+
log "Image size: $size"
62+
63+
else
64+
log "❌ Failed to build $IMAGE_NAME:$tag"
65+
exit 1
66+
fi
67+
}
68+
69+
# Test the built image
70+
test_image() {
71+
local tag="${1:-latest}"
72+
73+
log "Testing $IMAGE_NAME:$tag..."
74+
75+
# Run basic health check
76+
if docker run --rm "$IMAGE_NAME:$tag" test; then
77+
log "✅ Image test passed"
78+
else
79+
log "❌ Image test failed"
80+
return 1
81+
fi
82+
}
83+
84+
# Push image to registry
85+
push_image() {
86+
local tag="${1:-latest}"
87+
local registry="${2:-}"
88+
89+
if [ -n "$registry" ]; then
90+
local full_name="$registry/$IMAGE_NAME:$tag"
91+
92+
log "Tagging image for registry: $full_name"
93+
docker tag "$IMAGE_NAME:$tag" "$full_name"
94+
95+
log "Pushing to registry: $full_name"
96+
docker push "$full_name"
97+
98+
if [ $? -eq 0 ]; then
99+
log "✅ Successfully pushed $full_name"
100+
else
101+
log "❌ Failed to push $full_name"
102+
exit 1
103+
fi
104+
else
105+
log "No registry specified, skipping push"
106+
fi
107+
}
108+
109+
# Main function
110+
main() {
111+
local command="${1:-build}"
112+
local tag="${2:-latest}"
113+
local registry="${3:-}"
114+
115+
check_docker
116+
117+
case "$command" in
118+
build)
119+
build_image "$tag"
120+
;;
121+
test)
122+
test_image "$tag"
123+
;;
124+
push)
125+
push_image "$tag" "$registry"
126+
;;
127+
all)
128+
build_image "$tag"
129+
test_image "$tag"
130+
if [ -n "$registry" ]; then
131+
push_image "$tag" "$registry"
132+
fi
133+
;;
134+
*)
135+
echo "Usage: $0 {build|test|push|all} [tag] [registry]"
136+
echo ""
137+
echo "Commands:"
138+
echo " build - Build the Docker image"
139+
echo " test - Test the built image"
140+
echo " push - Push image to registry"
141+
echo " all - Build, test, and optionally push"
142+
echo ""
143+
echo "Examples:"
144+
echo " $0 build"
145+
echo " $0 build v1.0.0"
146+
echo " $0 push latest ghcr.io"
147+
echo " $0 all latest ghcr.io"
148+
exit 1
149+
;;
150+
esac
151+
}
152+
153+
# Run main function
154+
main "$@"

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ jobs:
135135
cache-from: type=gha
136136
cache-to: type=gha,mode=max
137137
platforms: linux/amd64,linux/arm64
138+
build-args: |
139+
BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
140+
VCS_REF=${{ github.sha }}
138141
139142
- name: Test Docker image
140143
run: |

0 commit comments

Comments
 (0)