Spaces:
Runtime error
Runtime error
| # Use an official Python base image (Python 3.10.12-slim) | |
| FROM python:3.10.12-slim | |
| # Prevent interactive prompts during package installation | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Suppress TensorFlow warnings | |
| ENV TF_CPP_MIN_LOG_LEVEL=2 | |
| # Set environment variables for Matplotlib, Hugging Face Transformers, and Pip cache | |
| ENV MPLCONFIGDIR=/app/.config/matplotlib | |
| ENV HF_HOME=/app/.cache/huggingface/hub | |
| ENV PIP_CACHE_DIR=/app/.cache/pip | |
| ENV HOME=/home/appuser | |
| # Create necessary directories for caches and configs | |
| RUN mkdir -p $MPLCONFIGDIR \ | |
| && mkdir -p $HF_HOME \ | |
| && mkdir -p $PIP_CACHE_DIR | |
| # Set the working directory to /app | |
| WORKDIR /app | |
| # Install system dependencies required for OpenCV and other packages | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| build-essential \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | |
| # Upgrade pip to the latest version | |
| RUN pip install --no-cache-dir -U pip tensorflow-cpu | |
| # Clone the Fooocus repository | |
| RUN git clone https://github.com/lllyasviel/Fooocus.git /app/Fooocus | |
| # Set the working directory to the Fooocus folder | |
| WORKDIR /app/Fooocus | |
| # Install the required Python packages listed in requirements_versions.txt | |
| RUN pip install --no-cache-dir -U -r requirements_versions.txt | |
| # Copy the local application files into the container | |
| COPY . . | |
| # Create a non-root user and group with UID and GID 1000 | |
| RUN groupadd -g 1000 appgroup && \ | |
| useradd -m -u 1000 -g appgroup appuser | |
| # Change ownership of the /app directory to the non-root user | |
| RUN chown -R appuser:appgroup /app | |
| # Switch to the non-root user | |
| USER appuser | |
| # Expose the necessary port | |
| EXPOSE 7860 | |
| # Set environment variables for the non-root user | |
| ENV HOME=/home/appuser | |
| ENV PATH=$HOME/.local/bin:$PATH | |
| # Command to run the Python script | |
| CMD ["python", "entry_with_update.py", "--share", "--always-cpu"] |