File size: 993 Bytes
d6d410e
 
fb9600d
d6d410e
fb9600d
 
d6d410e
 
fb9600d
d6d410e
 
 
 
 
fb9600d
d6d410e
 
 
 
58668d3
 
 
 
 
 
 
 
d6d410e
c2a07d1
fb9600d
d6d410e
ffabdb7
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
# Use official Python slim image
FROM python:3.9-slim

# Set working directory inside the container
WORKDIR /app

# Copy all files from current directory to /app in the container
COPY . /app

# Install system dependencies for PIL and PyTorch
RUN apt-get update && apt-get install -y \
    gcc \
    libgl1-mesa-glx \
    && rm -rf /var/lib/apt/lists/*

# Upgrade pip and install python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# create cache folder with write permissions
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface

# set environment variables for huggingface cache
ENV HF_HOME=/app/.cache/huggingface
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
ENV HF_DATASETS_CACHE=/app/.cache/huggingface/datasets

# Expose the port your FastAPI app will run on (7860 is standard on Hugging Face Spaces)
EXPOSE 7860

# Run the FastAPI app with uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]