system-prompts-and-models-o.../salesflow-saas/backend/Dockerfile
Claude e5aa1cade6
fix(railway): healthcheck path + dynamic PORT + start.sh wrapper
Railway healthcheck was failing because:
1. healthcheckPath was /api/v1/health but endpoint is /health
2. CMD used hardcoded port 8000, Railway injects $PORT dynamically
3. ${PORT:-8000} doesn't expand without shell

Fix:
- railway.toml: healthcheckPath = "/health"
- start.sh: shell wrapper that expands $PORT properly
- Dockerfile CMD: ["./start.sh"] instead of direct uvicorn
- HEALTHCHECK: uses /health (matches root endpoint)
- start-period increased to 90s for cold start

https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
2026-04-25 19:38:32 +00:00

46 lines
1.3 KiB
Docker

# ── Stage 1: Builder ──────────────────────────────────
FROM python:3.12-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libpq-dev curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
&& pip install --no-cache-dir -r requirements.txt
# ── Stage 2: Runtime ─────────────────────────────────
FROM python:3.12-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 curl tini \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd --gid 1000 app \
&& useradd --uid 1000 --gid app --shell /bin/bash --create-home app
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
WORKDIR /app
COPY --chown=app:app . .
RUN chmod +x start.sh
USER app
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=5 \
CMD curl -f http://localhost:${PORT:-8000}/health || exit 1
ENTRYPOINT ["tini", "--"]
CMD ["./start.sh"]