Spaces:
Sleeping
Sleeping
# Use the official Python image | |
FROM python:3.10-slim | |
# Set environment variables to prevent Python from writing .pyc files and buffering stdout | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
# Create writable directories for nltk_data and huggingface_cache | |
RUN mkdir -p /app/nltk_data && \ | |
mkdir -p /app/huggingface_cache && \ | |
chmod -R 777 /app/nltk_data && \ | |
chmod -R 777 /app/huggingface_cache | |
# Set environment variables for NLTK and Hugging Face cache directories | |
ENV NLTK_DATA=/app/nltk_data | |
ENV HF_HOME=/app/huggingface_cache | |
# Set working directory | |
WORKDIR /app | |
# Copy requirements.txt into the container | |
COPY requirements.txt /app/ | |
# Install Python dependencies | |
RUN pip install --upgrade pip | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Install spaCy and download the en_core_web_sm model | |
RUN pip install spacy | |
RUN python -m spacy download en_core_web_sm | |
# Copy the FastAPI app code into the container | |
COPY . /app/ | |
# Expose the port for the FastAPI app | |
EXPOSE 7860 | |
# Run FastAPI app using uvicorn | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |