leavoigt commited on
Commit
a15a4e0
·
verified ·
1 Parent(s): 5482965

Create custom_startup.sh

Browse files
Files changed (1) hide show
  1. custom_startup.sh +47 -0
custom_startup.sh ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # --- DEBUG: Print DOTENV_LOCAL value ---
4
+ echo "=== DEBUG: DOTENV_LOCAL VALUE ==="
5
+ echo "$DOTENV_LOCAL"
6
+ echo "=== END DEBUG ==="
7
+
8
+ # --- 1. Handle .env.local ---
9
+ ENV_LOCAL_PATH=/app/.env.local
10
+ if test -z "${DOTENV_LOCAL}" ; then
11
+ if ! test -f "${ENV_LOCAL_PATH}" ; then
12
+ echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. Make sure to set environment variables properly. "
13
+ fi;
14
+ else
15
+ echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file."
16
+ cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH}
17
+ fi;
18
+
19
+ # --- 2. Create MongoDB Data Directory ---
20
+ echo "Ensuring MongoDB data directory exists and has correct permissions ON PERSISTENT VOLUME..."
21
+ mkdir -p /data/db
22
+ chown -R user:user /data/db
23
+ echo "MongoDB data directory setup complete."
24
+
25
+ # --- 3. Create Models Directory (NEW FIX) ---
26
+ # This directory is expected by the app even when using remote endpoints.
27
+ echo "Ensuring models directory exists and has correct permissions ON PERSISTENT VOLUME..."
28
+ mkdir -p /data/models # <--- ADD THIS LINE
29
+ chown -R user:user /data/models # <--- ADD THIS LINE
30
+ echo "Models directory setup complete."
31
+
32
+ # --- 4. Start MongoDB ---
33
+ echo "Starting local MongoDB instance..."
34
+ nohup mongod &
35
+ echo "MongoDB started in background. Waiting a few seconds for it to initialize..."
36
+ sleep 5
37
+
38
+ # --- 5. Handle PUBLIC_VERSION (Patch for base image's bug) ---
39
+ echo "Setting PUBLIC_VERSION (patching base image's package.json lookup bug)..."
40
+ if [ -z "$PUBLIC_VERSION" ]; then
41
+ export PUBLIC_VERSION="0.2"
42
+ fi
43
+ echo "PUBLIC_VERSION set to: $PUBLIC_VERSION"
44
+
45
+ # --- 6. Start ChatUI Application ---
46
+ echo "Starting ChatUI application..."
47
+ exec dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000