Update start.sh to handle different repository structures

This commit is contained in:
Andreas Düren 2025-03-14 21:30:04 +01:00
parent d11f21f13f
commit 528a6eed66

View File

@ -83,16 +83,46 @@ sed -i \
-e "s|%%S3_PREFIX%%|${S3_PREFIX:-ente/}|g" \
/app/data/config/config.yaml
# Change to server directory
cd /app/code/server
# 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
# Run database migrations
echo "==> Running database migrations"
NODE_ENV=production yarn run db-migrate
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 "$SERVER_DIR"
# 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 || {
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"
exec /usr/local/bin/gosu cloudron:cloudron NODE_ENV=production CONFIG_PATH=/app/data/config/config.yaml yarn run serve
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