Spaces:
Sleeping
Sleeping
| # Multi-stage build: Build frontend first | |
| FROM node:18-bullseye AS frontend-build | |
| # Create app directory | |
| WORKDIR /app | |
| # Copy frontend files | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| # Copy frontend source | |
| COPY frontend/ ./ | |
| # Build the frontend | |
| RUN npm run build | |
| # Backend build | |
| FROM node:18-bullseye AS backend-build | |
| WORKDIR /app | |
| COPY backend/package*.json ./ | |
| RUN npm install | |
| COPY backend/ ./ | |
| # Final stage | |
| FROM node:18-bullseye | |
| # Install serve globally to serve frontend | |
| RUN npm install -g serve | |
| # Create app directory | |
| WORKDIR /app | |
| # Copy built frontend from frontend-build stage | |
| COPY --from=frontend-build /app/dist ./frontend/dist | |
| # Setup backend | |
| COPY --from=backend-build /app ./backend | |
| # Copy startup script | |
| COPY start.sh . | |
| RUN chmod +x start.sh | |
| # Expose the port that Hugging Face Spaces expects | |
| EXPOSE 8501 | |
| # Start both services | |
| CMD ["./start.sh"] |