ppsingh commited on
Commit
cf6e149
·
verified ·
1 Parent(s): 35ce841

Create custom-startup.sh

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