Spaces:
Sleeping
Sleeping
| FROM node:20-alpine AS frontend-builder | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| COPY frontend ./ | |
| RUN npm run build | |
| FROM python:3.10-slim | |
| # Install Node.js | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | |
| && apt-get install -y nodejs \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Setup Backend | |
| COPY backend/requirements.txt backend/ | |
| RUN pip install --no-cache-dir -r backend/requirements.txt | |
| COPY backend backend/ | |
| # Setup Frontend | |
| COPY frontend/package*.json frontend/ | |
| WORKDIR /app/frontend | |
| RUN npm install --omit=dev | |
| COPY --from=frontend-builder /app/frontend/.next ./.next | |
| COPY --from=frontend-builder /app/frontend/public ./public | |
| # We need the source files for Next.js to run in production for App Router depending on setup, but mostly .next and node_modules are enough. | |
| COPY frontend/next.config.mjs ./ | |
| WORKDIR /app | |
| # Create a start script | |
| COPY start.sh . | |
| RUN chmod +x start.sh | |
| # Expose the port Hugging Face expects | |
| EXPOSE 7860 | |
| # Run both servers | |
| CMD ["./start.sh"] | |