Spaces:
Sleeping
Sleeping
| # ---------- build frontend ---------- | |
| FROM node:20-bookworm AS frontend-build | |
| WORKDIR /frontend | |
| COPY frontend/package.json ./ | |
| RUN npm install | |
| COPY frontend/ . | |
| RUN npm run build | |
| # ---------- runtime ---------- | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Backend deps | |
| COPY backend/requirements.txt /app/backend/requirements.txt | |
| RUN pip install --no-cache-dir -r /app/backend/requirements.txt | |
| # Download and save model during build (so it persists across restarts) | |
| # This prevents re-downloading the model on every container restart | |
| RUN mkdir -p /app/Model/bert-tiny && \ | |
| python3 -c "from transformers import AutoTokenizer, AutoModel; \ | |
| print('Downloading BERT-tiny model during build...'); \ | |
| tokenizer = AutoTokenizer.from_pretrained('prajjwal1/bert-tiny'); \ | |
| model = AutoModel.from_pretrained('prajjwal1/bert-tiny'); \ | |
| print('Saving model to /app/Model/bert-tiny...'); \ | |
| tokenizer.save_pretrained('/app/Model/bert-tiny'); \ | |
| model.save_pretrained('/app/Model/bert-tiny'); \ | |
| print('Model saved successfully!')" | |
| # Copy backend code | |
| COPY backend /app/backend | |
| # Copy frontend build into /app/frontend/dist | |
| COPY --from=frontend-build /frontend/dist /app/frontend/dist | |
| # Set PYTHONPATH so Python can find the app module | |
| ENV PYTHONPATH=/app/backend:$PYTHONPATH | |
| # HF Spaces uses port 7860 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |