Sgridda
Fix cache permissions using chmod
fe2db02
raw
history blame contribute delete
876 Bytes
# Use the official Python 3.9 slim image
FROM python:3.9-slim
# Set the working directory inside the container
WORKDIR /code
# Create a directory for the model cache and make it world-writable.
# This ensures that the non-root user running the app can write to it,
# without needing to know the user's name during the build.
RUN mkdir /code/cache && chmod 777 /code/cache
# Set the HF_HOME environment variable to point to our new cache directory.
ENV HF_HOME /code/cache
# Copy the requirements file and install dependencies
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Copy the application code
COPY ./main.py /code/main.py
# Command to run the FastAPI server.
# The Hugging Face platform will run this command as a non-root user.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]