dassbot / Dockerfile
brianhuster's picture
Deploy DASS-21 app to Hugging Face Space
a3ee1b6
Raw
History Blame Contribute Delete
1.17 kB
# --- Stage 1: Build React Frontend ---
FROM node:20-alpine AS frontend-builder
WORKDIR /app
COPY package*.json tsconfig*.json vite.config.* ./
RUN npm ci
COPY src/ ./src
COPY index.html ./
RUN npm run build
# --- Stage 2: Build FastAPI Backend ---
FROM python:3.11-slim
WORKDIR /app
# Install build essentials if needed
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install python dependencies directly
RUN pip install --no-cache-dir \
"fastapi>=0.115.0" \
"python-dotenv>=1.0.1" \
"uvicorn>=0.30.0" \
"transformers>=4.45.0" \
"safetensors>=0.4.0" \
https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp311-cp311-linux_x86_64.whl
# Copy backend files
COPY app.py ./
# Copy built frontend assets from Stage 1 to the dist folder
COPY --from=frontend-builder /app/dist ./dist
# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=7860
ENV BERT_MODEL_DIR=brianhuster/dass_bert
# Expose the default port (Hugging Face Spaces uses 7860 by default)
EXPOSE 7860
# Run FastAPI app
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]