File size: 1,792 Bytes
5cb2bb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Dockerfile for Perchance Image-Generation Server (for Hugging Face Spaces)
# Based on Debian-slim + Python. Installs Chromium runtime libs so zendriver
# can operate in headless mode where allowed.
FROM python:3.12-slim

# runtime env
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PORT=7860 \
    ZD_HEADLESS=true \
    NO_INITIAL_FETCH=true

WORKDIR /app

# install system deps (chromium runtime libs + common utils)
RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    gnupg \
    wget \
    unzip \
    fonts-liberation \
    libnss3 \
    libxss1 \
    libasound2 \
    libatk1.0-0 \
    libcups2 \
    libx11-xcb1 \
    libxcomposite1 \
    libxdamage1 \
    libxrandr2 \
    libgbm1 \
    libgtk-3-0 \
    libxshmfence1 \
    procps \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Install Chromium (Debian's package name may vary across distros).
# In many slim images the package is "chromium" or "chromium-browser".
# Try chromium; if your target base differs, change accordingly.
RUN apt-get update && apt-get install -y --no-install-recommends chromium \
    || true && rm -rf /var/lib/apt/lists/*

# Safety: set CHROME_BIN to where Chromium usually is installed
ENV CHROME_BIN=/usr/bin/chromium

# copy requirements first (docker layer caching)
COPY requirements.txt /app/requirements.txt

# upgrade pip and install python deps
RUN python -m pip install --upgrade pip setuptools wheel \
 && pip --no-cache-dir install -r /app/requirements.txt

# copy app sources
COPY . /app

# make start script executable
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh

# expose port
EXPOSE ${PORT}

# Start the server.
# Use sh -c so ${PORT} expansion works in exec form.
CMD ["sh", "-c", "/app/start.sh"]