#!/bin/sh set -e # Install the muse package if the dev volume mount is present. # This lets the server-side release analysis service import muse.plugins.code. if [ -f /muse/pyproject.toml ]; then echo "Muse volume detected — installing muse in editable mode..." pip install -e /muse --quiet --root-user-action=ignore 2>/dev/null || true fi # Install the muse_contracts package if the dev volume mount is present. # Provides shared cross-repo type contracts (IssueRecord, ProposalRecord, etc.). # Copy to /tmp first so setuptools can write egg-info without hitting the # read-only bind-mount. if [ -f /src/contracts/pyproject.toml ]; then echo "Contracts volume detected — installing muse_contracts..." cp -r /src/contracts /tmp/muse-contracts-install pip install /tmp/muse-contracts-install --quiet --root-user-action=ignore 2>/dev/null || true rm -rf /tmp/muse-contracts-install fi # If a command was passed (e.g., "alembic upgrade head" from the deploy script), # run it directly without starting the server. if [ $# -gt 0 ]; then exec "$@" fi # Blue-green deploys run migrations as a one-off before starting the new slot, # so the new container starts clean without re-running them. # Set SKIP_MIGRATIONS=1 in the new container to skip this step. if [ "${SKIP_MIGRATIONS:-0}" = "1" ]; then echo "SKIP_MIGRATIONS=1 — skipping alembic (already run by deploy script)" else echo "Running database migrations..." alembic upgrade head fi echo "Starting MuseHub..." exec uvicorn musehub.main:app \ --host 0.0.0.0 \ --port 10003 \ --workers "${UVICORN_WORKERS:-4}" \ --proxy-headers \ --forwarded-allow-ips='*'