File size: 1,118 Bytes
2e7ed2d
 
3834a14
2e7ed2d
 
3834a14
911130a
 
 
dfcc57e
 
911130a
1de9706
 
 
 
 
 
911130a
2e7ed2d
 
3834a14
2e7ed2d
 
3834a14
2e7ed2d
 
383ed8c
2e7ed2d
 
 
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
# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /code

# Set environment variables to tell Hugging Face libraries where to cache models.
ENV HF_HOME=/code/cache
ENV HF_HUB_CACHE=/code/cache
# Deprecated but harmless
ENV TRANSFORMERS_CACHE=/code/cache

# --- FIX FOR PERMISSION ERROR v2 ---
# Create the cache directory AND give it open write permissions for all users.
# This ensures that the non-root user running the CMD can write to it.
RUN mkdir -p /code/cache && \
    chmod -R 777 /code/cache
# -----------------------------------

# Copy the requirements file into the container at /code
COPY ./requirements.txt /code/requirements.txt

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy the rest of the application code into the container at /code
COPY ./main.py /code/main.py

# Command to run the app using uvicorn.
# It will be available on port 7860, the standard for HF Spaces
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]