Commit 528a6eed authored by Andreas Düren's avatar Andreas Düren
Browse files

Update start.sh to handle different repository structures

parent d11f21f1
Loading
Loading
Loading
Loading
+36 −6
Original line number Diff line number Diff line
@@ -83,16 +83,46 @@ sed -i \
    -e "s|%%S3_PREFIX%%|${S3_PREFIX:-ente/}|g" \
    /app/data/config/config.yaml

# Find the correct server directory
SERVER_DIR=""
for dir in "/app/code/server" "/app/code/packages/server"; do
    if [ -f "$dir/package.json" ]; then
        SERVER_DIR="$dir"
        break
    fi
done

if [ -z "$SERVER_DIR" ]; then
    echo "==> ERROR: Could not find server directory with package.json"
    echo "    Server directory structure may have changed."
    echo "    Please check the ente repository structure."
    exit 1
fi

echo "==> Found server directory at $SERVER_DIR"

# Change to server directory
cd /app/code/server
cd "$SERVER_DIR"

# Run database migrations
# Run database migrations if the script exists
if grep -q "\"db-migrate\"" package.json; then
    echo "==> Running database migrations"
NODE_ENV=production yarn run db-migrate
    NODE_ENV=production yarn run db-migrate || {
        echo "==> WARNING: Database migration failed, but continuing anyway"
    }
else
    echo "==> Skipping database migrations (script not found)"
fi

# Change ownership to cloudron user
chown -R cloudron:cloudron /app/data

# Start the server
echo "==> Starting Ente server"
if grep -q "\"serve\"" package.json; then
    exec /usr/local/bin/gosu cloudron:cloudron NODE_ENV=production CONFIG_PATH=/app/data/config/config.yaml yarn run serve
else
    echo "==> ERROR: Could not find 'serve' script in package.json"
    echo "    Please check the ente repository structure."
    exit 1
fi 
 No newline at end of file