File size: 2,293 Bytes
8a58a6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Use Python 3.10 base image
FROM python:3.10-slim-bullseye

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3-dev \
    python3-venv \
    python3-pip \
    python3-tk \
    git \
    wget \
    curl \
    build-essential \
    libgl1-mesa-glx \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    libgomp1 \
    software-properties-common \
    && rm -rf /var/lib/apt/lists/*


# Set working directory
WORKDIR /app

# Copy requirements first to leverage Docker cache
COPY requirements.txt .

# Upgrade pip and install uv for faster package installation
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install uv

# Install PyTorch with CUDA support
RUN python3 -m uv pip install --system --index-url https://download.pytorch.org/whl/cu128 \
    torch torchvision  "triton>=2.1.0"

# Install numpy with version constraint
RUN python3 -m uv pip install --system "numpy<2.0.0"

# Install Python dependencies
RUN python3 -m uv pip install --system -r requirements.txt

# Copy the entire project
COPY . .

# Create necessary directories
RUN mkdir -p ./_internal/output/classic \
    ./_internal/output/Flux \
    ./_internal/output/HiresFix \
    ./_internal/output/Img2Img \
    ./_internal/output/Adetailer \
    ./_internal/checkpoints \
    ./_internal/clip \
    ./_internal/embeddings \
    ./_internal/ESRGAN \
    ./_internal/loras \
    ./_internal/sd1_tokenizer \
    ./_internal/unet \
    ./_internal/vae \
    ./_internal/vae_approx \
    ./_internal/yolos

# Create last_seed.txt if it doesn't exist
RUN echo "42" > ./_internal/last_seed.txt

# Create prompt.txt if it doesn't exist
RUN echo "A beautiful landscape" > ./_internal/prompt.txt

# Expose the port that Gradio will run on
EXPOSE 7860

# Set environment variable to indicate this is running in a container
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
  CMD curl -f http://localhost:7860/ || exit 1

# Run the Gradio app
CMD ["python3", "app.py"]