-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·44 lines (38 loc) · 1.57 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.57 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
#!/bin/bash
set -e
echo "╔══════════════════════════════════════════╗"
echo "║ OpenCodeHub Starting... ║"
echo "╚══════════════════════════════════════════╝"
# Wait for database to be ready
if [ -n "$DATABASE_URL" ]; then
echo "⏳ Waiting for database..."
for i in $(seq 1 30); do
if bun -e "
const pg = require('pg');
const client = new pg.Client(process.env.DATABASE_URL);
client.connect().then(() => { client.end(); process.exit(0); }).catch(() => process.exit(1));
" 2>/dev/null; then
echo "✅ Database is ready"
break
fi
if [ "$i" -eq 30 ]; then
echo "⚠️ Database not reachable after 30s, proceeding anyway..."
fi
sleep 1
done
# Run database migrations
echo "🔄 Running database migrations..."
cd /app
bunx drizzle-kit push --force 2>/dev/null || echo "⚠️ Migration push skipped (may already be up to date)"
echo "✅ Migrations complete"
fi
# Initialize SSH host key if not exists
if [ -n "$SSH_HOST_KEY_PATH" ] && [ ! -f "$SSH_HOST_KEY_PATH" ]; then
echo "🔑 Generating SSH host key..."
ssh-keygen -t ed25519 -f "$SSH_HOST_KEY_PATH" -N "" -q
echo "✅ SSH host key generated"
fi
# Create required directories
mkdir -p "${REPOS_PATH:-/data/repos}" "${STORAGE_PATH:-/data/storage}" "${CACHE_PATH:-/data/cache}"
echo "🚀 Starting OpenCodeHub on port ${PORT:-4321}..."
exec bun ./dist/server/entry.mjs