| |
| FROM node:20-slim AS frontend-builder |
|
|
| WORKDIR /src/dashboard |
|
|
| |
| COPY dashboard/package*.json ./ |
| RUN npm install |
|
|
| |
| COPY dashboard/ . |
| RUN npm run build |
|
|
| |
| FROM python:3.11-slim AS python-builder |
|
|
| WORKDIR /build-python |
|
|
| |
| WORKDIR /app |
| RUN python -m venv /app/venv |
| ENV PATH="/app/venv/bin:$PATH" |
|
|
| |
| COPY requirements.txt . |
| RUN pip install --no-cache-dir -r requirements.txt |
|
|
| |
| FROM python:3.11-slim AS production |
|
|
| |
| RUN useradd --create-home --shell /bin/bash appuser |
|
|
| WORKDIR /app |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| curl \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| ENV PATH="/app/venv/bin:$PATH" |
| ENV PYTHONPATH="/app" |
|
|
| |
| COPY --from=python-builder /app/venv /app/venv |
|
|
| |
| |
| COPY --chown=appuser:appuser --from=frontend-builder /src/static/dashboard /app/static/dashboard |
|
|
| |
| COPY --chown=appuser:appuser . . |
|
|
| |
| RUN mkdir -p /app/data && chown appuser:appuser /app/data |
|
|
| |
| USER appuser |
|
|
| |
| ENV PATH="/app/venv/bin:$PATH" |
| ENV PYTHONPATH="/app" |
| ENV APP_PORT=7860 |
|
|
| EXPOSE 7860 |
|
|
| HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \ |
| CMD curl -f http://localhost:7860/health || exit 1 |
|
|
| |
| CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |
|
|