File size: 1,108 Bytes
e2356be
e311c25
 
e2356be
 
 
e311c25
e2356be
 
 
 
 
e311c25
e2356be
 
 
e311c25
e2356be
 
e311c25
e2356be
 
e311c25
e2356be
 
 
 
536e93b
 
 
 
e2356be
 
 
 
 
e311c25
e2356be
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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"]