CoolFace
Apppublic

random0011/xai_image

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
Dockerfile37 linesDownload Raw Back to root
1# Start with an official Python base image.2FROM python:3.9-slim3 4# Set the working directory inside the container.5WORKDIR /code6 7# --- FIX: Create a writable cache directory and set ownership ---8# 1. Define where the caches should go using environment variables.9ENV TORCH_HOME=/code/cache/torch10ENV MPLCONFIGDIR=/code/cache/matplotlib11 12# 2. During the build (as root), create the cache directory and then13#    change its ownership to the 'user' (uid 1000) that will run the app.14#    This is the key fix.15RUN mkdir -p /code/cache && \16    chown -R 1000:1000 /code/cache17 18# --- Standard Setup ---19# Copy the requirements file.20COPY ./requirements.txt /code/requirements.txt21 22# Install dependencies.23RUN pip install --no-cache-dir --upgrade pip && \24    pip install --no-cache-dir -r requirements.txt --default-timeout=10025 26# Copy the application code.27COPY ./main.py /code/main.py28 29# Switch to the non-root user that Hugging Face will use.30# This is good practice and ensures the app runs with the correct permissions.31USER 100032 33# Expose the required port.34EXPOSE 786035 36# Command to run the application.37CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]