Spaces:
Runtime error
Runtime error
File size: 2,394 Bytes
2311c41 6ffc5e3 749878d 6ffc5e3 673e3c2 2311c41 673e3c2 749878d 6ffc5e3 749878d 6ffc5e3 2311c41 6ffc5e3 749878d 6ffc5e3 2311c41 6ffc5e3 2311c41 6ffc5e3 2311c41 6ffc5e3 2311c41 6ffc5e3 2311c41 6ffc5e3 2311c41 | 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # Dockerfile for Hugging Face Space with Diffusers-based image generation
FROM python:3.10-slim
# Environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
DEBIAN_FRONTEND=noninteractive \
PYTHONIOENCODING=utf-8 \
# Set Hugging Face cache directory
HF_HOME=/app/.cache \
HF_HUB_CACHE=/app/.cache \
TRANSFORMERS_CACHE=/app/.cache \
# Set Git identity via environment variables to avoid permission issues
GIT_AUTHOR_NAME="Defter77" \
GIT_AUTHOR_EMAIL="Defter77@users.noreply.huggingface.co" \
GIT_COMMITTER_NAME="Defter77" \
GIT_COMMITTER_EMAIL="Defter77@users.noreply.huggingface.co"
# System dependencies without git (we'll install our own wrapper)
RUN apt-get update && apt-get install -y \
wget \
curl \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Create a git wrapper script that ignores git config commands
RUN echo '#!/bin/sh' > /usr/local/bin/git && \
echo 'if [ "$1" = "config" ] && [ "$2" = "--global" ]; then' >> /usr/local/bin/git && \
echo ' echo "Git config bypassed"' >> /usr/local/bin/git && \
echo 'else' >> /usr/local/bin/git && \
echo ' /usr/bin/git "$@"' >> /usr/local/bin/git && \
echo 'fi' >> /usr/local/bin/git && \
chmod +x /usr/local/bin/git
# Actually install real git (our wrapper will intercept config commands)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Create cache and data directories with proper permissions
RUN mkdir -p /app/.cache /app/input /app/output && \
chmod -R 777 /app/.cache /app/input /app/output
# Copy requirements
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Add model download script
COPY download_models.py ./
RUN python download_models.py || echo "Warning: Model download may have had issues, but continuing build"
# Copy application code
COPY app.py ./
COPY inference.py ./
# Expose API port
EXPOSE 7860
# Optional health check
HEALTHCHECK --interval=30s --timeout=10s CMD curl --fail http://localhost:7860/docs || exit 1
# Run FastAPI app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|