-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathentrypoint.sh
More file actions
53 lines (47 loc) · 1.8 KB
/
entrypoint.sh
File metadata and controls
53 lines (47 loc) · 1.8 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
#!/bin/bash
# Entrypoint for OpenShift compatibility.
# OpenShift runs containers as a random UID in GID 0. K8s subPath
# volume mounts create intermediate directories as root, making
# ~/.config non-writable. XDG_CONFIG_HOME redirects config writes
# to a writable location.
# Copy cursor credentials from PVC staging mount
if [ -d /cursor-credentials ]; then
mkdir -p "${XDG_CONFIG_HOME:-/home/appuser/.config}/cursor"
cp -a /cursor-credentials/. "${XDG_CONFIG_HOME:-/home/appuser/.config}/cursor/"
fi
# Resolve PORT with a default so the exec-form CMD (which cannot expand
# shell variables) gets the correct bind port at runtime.
export PORT="${PORT:-8000}"
# Dev mode: start Vite dev server in background for frontend HMR
if [ "${DEV_MODE:-}" = "true" ] && [ -f /app/frontend/package.json ]; then
echo "[DEV] Frontend source detected, starting Vite dev server..."
cd /app/frontend || { echo "[DEV] Failed to change to frontend directory"; exit 1; }
if [ ! -d node_modules ]; then
echo "[DEV] Installing frontend dependencies..."
npm install --no-audit --no-fund
fi
npm run dev -- --host 0.0.0.0 --port 5173 &
cd /app || { echo "[DEV] Failed to return to app directory"; exit 1; }
fi
# Check if any argument contains "uvicorn" to detect all uvicorn invocations
has_uvicorn=false
has_port=false
for arg in "$@"; do
case "$arg" in
*uvicorn*) has_uvicorn=true ;;
--port|--port=*) has_port=true ;;
esac
done
# Build final arguments
extra_args=""
if [ "$has_uvicorn" = true ] && [ "$has_port" = false ]; then
extra_args="$extra_args --port $PORT"
fi
if [ "$has_uvicorn" = true ] && [ "${DEV_MODE:-}" = "true" ]; then
extra_args="$extra_args --reload --reload-dir /app/src"
fi
if [ -n "$extra_args" ]; then
exec "$@" $extra_args
else
exec "$@"
fi