| # --- Backend Build Stage --- | |
| FROM python:3.9-slim as backend | |
| WORKDIR /app | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY backend/ ./backend | |
| COPY routes/ ./routes | |
| COPY templates/ ./templates | |
| COPY static/ ./static | |
| # --- Frontend Build Stage --- | |
| FROM node:18 as frontend | |
| WORKDIR /app | |
| COPY frontend/agentic-dashboard/package*.json ./ | |
| RUN npm install --legacy-peer-deps | |
| COPY frontend/agentic-dashboard/ . | |
| RUN npm run build | |
| # --- Final Runtime Stage --- | |
| FROM python:3.9-slim | |
| WORKDIR /app | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --force-reinstall -r requirements.txt | |
| # Copy backend + frontend artifacts | |
| COPY --from=backend /app /app | |
| COPY --from=frontend /app/dist/agentic-dashboard /app/static | |
| # Set Flask app and expose port | |
| ENV FLASK_APP=backend.app | |
| EXPOSE 5000 | |
| CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "5000"] | |