File size: 1,531 Bytes
814be0d
1e18d61
 
 
 
 
 
 
 
 
 
 
fa76031
 
 
1e18d61
 
 
2ca2b41
1e18d61
2ca2b41
1e18d61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ca2b41
814be0d
 
9e88a99
 
 
1e18d61
9e88a99
 
902a245
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
41
42
43
44
45
46
47
48
49
50
51
52
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Disable Python buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Set environment variables for writable caches and config directories
ENV HOME=/tmp
ENV XDG_CACHE_HOME=/tmp/.cache
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV HF_HOME=/tmp/hf_home

# Optional: Force Transformers to use slow tokenizers
ENV TRANSFORMERS_NO_FAST=1

# Set the working directory in the container
WORKDIR /app

# Install system dependencies including build-essential for gcc
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    ffmpeg \
    libsm6 \
    libxext6 \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file into the container
COPY requirements.txt /app/requirements.txt

# Upgrade pip and install Python dependencies
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt

# Download spaCy's small English model
RUN python -m spacy download en_core_web_sm

# Create required directories with proper permissions
RUN mkdir -p /app/static /app/temp && chmod -R 777 /app/static /app/temp

# Copy the rest of your application code into the container
COPY . /app

# Set permissions for the entire /app directory (adjust for security if needed)
RUN chmod -R 777 /app

# Set a default port; Hugging Face Spaces sets PORT automatically
ENV PORT=7860
EXPOSE 7860

# Run the FastAPI application using uvicorn on the dynamic port
CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT}"]