-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
41 lines (31 loc) · 916 Bytes
/
entrypoint.sh
File metadata and controls
41 lines (31 loc) · 916 Bytes
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
#!/bin/sh
# Combined entrypoint: runs both backend and nginx
# Container exits if either process dies
set -e
cleanup() {
echo "Shutting down..."
kill $BACKEND_PID $NGINX_PID 2>/dev/null || true
exit ${1:-0}
}
trap 'cleanup 0' SIGTERM SIGINT
# Generate runtime config for frontend (API is now relative)
cat > /usr/share/nginx/html/config.js << 'EOF'
window.__RUNTIME_CONFIG__ = {
API_URL: "/api"
};
EOF
# Start backend on port 3000 (only accessible via nginx proxy)
cd /app && PORT=3000 pnpm --filter aurboda-backend start &
BACKEND_PID=$!
# Give backend a moment to start
sleep 2
# Start nginx
nginx -g 'daemon off;' &
NGINX_PID=$!
echo "Aurboda started - backend PID: $BACKEND_PID, nginx PID: $NGINX_PID"
# Monitor both processes - exit if either dies
while kill -0 $BACKEND_PID 2>/dev/null && kill -0 $NGINX_PID 2>/dev/null; do
sleep 2
done
echo "Process exited unexpectedly"
cleanup 1