Spaces:
Running
Running
| # ββ Stage 1: Build Frontend ββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM node:20-slim AS frontend-build | |
| WORKDIR /build | |
| COPY frontend/package.json frontend/package-lock.json* ./ | |
| RUN npm ci --no-audit --no-fund | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # ββ Stage 2: Final Image ββββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.11-slim | |
| # Install nginx and supervisor | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends nginx supervisor && \ | |
| rm -rf /var/lib/apt/lists/* && \ | |
| mkdir -p /var/log/supervisor | |
| WORKDIR /app | |
| # Install Python dependencies | |
| COPY backend/requirements.txt ./requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt supervisor | |
| # Copy backend code | |
| COPY backend/app ./app | |
| # Copy built frontend | |
| COPY --from=frontend-build /build/dist /app/frontend/dist | |
| # Copy configs | |
| COPY nginx.conf /etc/nginx/nginx.conf | |
| COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
| # Create non-root user (HF Spaces requirement) | |
| RUN useradd -m -u 1000 appuser && \ | |
| chown -R appuser:appuser /app && \ | |
| chown -R appuser:appuser /var/log/nginx && \ | |
| chown -R appuser:appuser /var/lib/nginx && \ | |
| chown -R appuser:appuser /var/log/supervisor && \ | |
| touch /run/nginx.pid && \ | |
| chown appuser:appuser /run/nginx.pid | |
| USER appuser | |
| EXPOSE 7860 | |
| CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] | |