Spaces:
Sleeping
Sleeping
| # Single-stage, slim image for a single deployable service. | |
| FROM python:3.12-slim | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 | |
| WORKDIR /app | |
| # Install dependencies first to leverage layer caching. | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the application. | |
| COPY app ./app | |
| COPY scripts ./scripts | |
| # Persisted SQLite lives here; mount a volume to keep data across restarts. | |
| ENV DATABASE_URL=sqlite:////data/interviewcoach.db | |
| RUN mkdir -p /data | |
| # Run as a non-root user. | |
| RUN useradd --create-home --uid 10001 appuser && chown -R appuser /app /data | |
| USER appuser | |
| EXPOSE 8000 | |
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ | |
| CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8000/health').status==200 else 1)" | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] | |