-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·50 lines (40 loc) · 1.27 KB
/
setup.sh
File metadata and controls
executable file
·50 lines (40 loc) · 1.27 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
#!/bin/bash
set -e
echo "CodeArena setup starting..."
# 1. Check Docker
if ! command -v docker &> /dev/null; then
echo "Docker is not installed. Please install Docker first."
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
echo "docker-compose is not installed."
exit 1
fi
echo "Docker found"
# 2. Start core services
echo "Starting Postgres and Redis..."
docker-compose up -d postgres redis
# 3. Wait for Postgres
echo "Waiting for Postgres to be ready..."
sleep 5
# 4. Apply DB schema
echo "Applying database schema..."
docker exec -i codearena-postgres-1 psql -U rankforge rankforge < db/schema.sql
docker exec -i codearena-postgres-1 psql -U rankforge rankforge < db/penalties.sql
docker exec -i codearena-postgres-1 psql -U rankforge rankforge < db/leaderboard_events.sql
# 5. Grant permissions
echo "Granting DB permissions..."
docker exec -i codearena-postgres-1 psql -U rankforge rankforge <<EOF
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO rankforge;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO rankforge;
EOF
echo "Database ready"
# 6. Final instructions
echo ""
echo "Setup complete!"
echo ""
echo "Next steps:"
echo " docker-compose up --build"
echo ""
echo "Frontend: http://localhost:3001"
echo "API: http://localhost:3000"