-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
126 lines (107 loc) · 3.35 KB
/
setup.sh
File metadata and controls
126 lines (107 loc) · 3.35 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
echo "================================================"
echo " CodeArena - Docker Implementation Setup"
echo "================================================"
echo ""
# Check Docker
echo "Step 1: Checking Docker installation..."
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed!"
echo "Please install Docker Desktop from: https://www.docker.com/products/docker-desktop"
exit 1
fi
if ! docker ps &> /dev/null; then
echo "❌ Docker is not running!"
echo "Please start Docker Desktop and try again."
exit 1
fi
echo "✅ Docker is installed and running"
echo ""
# Check Node.js
echo "Step 2: Checking Node.js installation..."
if ! command -v node &> /dev/null; then
echo "❌ Node.js is not installed!"
echo "Please install Node.js from: https://nodejs.org/"
exit 1
fi
NODE_VERSION=$(node -v)
echo "✅ Node.js is installed: $NODE_VERSION"
echo ""
# Install dependencies
echo "Step 3: Installing dependencies..."
npm install
echo "✅ Dependencies installed"
echo ""
# Build Docker images
echo "Step 4: Building Docker executor images..."
echo "This may take 5-10 minutes..."
echo ""
cd docker/scripts
# Build C++ image
echo "Building C++ executor..."
docker build -f ../executors/Dockerfile.cpp -t codearena-executor-cpp:latest ../executors/ || {
echo "❌ Failed to build C++ image"
exit 1
}
# Build Python image
echo "Building Python executor..."
docker build -f ../executors/Dockerfile.python -t codearena-executor-python:latest ../executors/ || {
echo "❌ Failed to build Python image"
exit 1
}
# Build Java image
echo "Building Java executor..."
docker build -f ../executors/Dockerfile.java -t codearena-executor-java:latest ../executors/ || {
echo "❌ Failed to build Java image"
exit 1
}
# Build JavaScript image
echo "Building JavaScript executor..."
docker build -f ../executors/Dockerfile.javascript -t codearena-executor-javascript:latest ../executors/ || {
echo "❌ Failed to build JavaScript image"
exit 1
}
# Build Go image
echo "Building Go executor..."
docker build -f ../executors/Dockerfile.go -t codearena-executor-go:latest ../executors/ || {
echo "❌ Failed to build Go image"
exit 1
}
cd ../..
echo ""
echo "✅ All Docker images built successfully!"
echo ""
# Verify images
echo "Step 5: Verifying images..."
docker images | grep codearena-executor
echo ""
# Create .env file if not exists
if [ ! -f .env.local ]; then
echo "Step 6: Creating .env.local file..."
cp .env.example .env.local
echo "✅ .env.local created"
else
echo "Step 6: .env.local already exists"
fi
echo ""
# Done
echo "================================================"
echo " ✅ Setup Complete!"
echo "================================================"
echo ""
echo "Next steps:"
echo " 1. Start development server: npm run dev"
echo " 2. Visit http://localhost:3000/test-docker"
echo " 3. Test code execution with different languages"
echo ""
echo "Useful commands:"
echo " - npm run dev : Start development server"
echo " - npm run docker:build : Rebuild Docker images"
echo " - npm run docker:cleanup : Clean up Docker resources"
echo ""
echo "Documentation:"
echo " - README.md : Project overview"
echo " - DOCKER_GUIDE.md : Detailed Docker guide"
echo " - IMPLEMENTATION_SUMMARY.md : Implementation details"
echo ""
echo "Happy coding! 🚀"