Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
| # --- DEBUG: Print DOTENV_LOCAL value --- | |
| echo "=== DEBUG: DOTENV_LOCAL VALUE ===" | |
| echo "$DOTENV_LOCAL" | |
| echo "=== END DEBUG ===" | |
| # --- 1. Handle .env.local --- | |
| ENV_LOCAL_PATH=/app/.env.local | |
| if test -z "${DOTENV_LOCAL}" ; then | |
| if ! test -f "${ENV_LOCAL_PATH}" ; then | |
| 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. " | |
| fi; | |
| else | |
| echo "DOTENV_LOCAL was found in the ENV variables. Creating .env.local file." | |
| cat <<< "$DOTENV_LOCAL" > ${ENV_LOCAL_PATH} | |
| fi; | |
| # --- 2. Create MongoDB Data Directory --- | |
| echo "Ensuring MongoDB data directory exists and has correct permissions ON PERSISTENT VOLUME..." | |
| mkdir -p /data/db | |
| chown -R user:user /data/db | |
| echo "MongoDB data directory setup complete." | |
| # --- 3. Create Models Directory (NEW FIX) --- | |
| # This directory is expected by the app even when using remote endpoints. | |
| echo "Ensuring models directory exists and has correct permissions ON PERSISTENT VOLUME..." | |
| mkdir -p /data/models # <--- ADD THIS LINE | |
| chown -R user:user /data/models # <--- ADD THIS LINE | |
| echo "Models directory setup complete." | |
| # --- 4. Start MongoDB --- | |
| echo "Starting local MongoDB instance..." | |
| nohup mongod & | |
| echo "MongoDB started in background. Waiting a few seconds for it to initialize..." | |
| sleep 5 | |
| # --- 5. Handle PUBLIC_VERSION (Patch for base image's bug) --- | |
| echo "Setting PUBLIC_VERSION (patching base image's package.json lookup bug)..." | |
| if [ -z "$PUBLIC_VERSION" ]; then | |
| export PUBLIC_VERSION="0.2" | |
| fi | |
| echo "PUBLIC_VERSION set to: $PUBLIC_VERSION" | |
| # --- 6. Start ChatUI Application --- | |
| echo "Starting ChatUI application..." | |
| exec dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000 |