AdarshJi commited on
Commit
deae676
·
verified ·
1 Parent(s): 54ab613

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -20
Dockerfile CHANGED
@@ -1,24 +1,23 @@
1
- # Dockerfile for Perchance Image-Generation Server (for Hugging Face Spaces)
2
- # Based on Debian-slim + Python. Installs Chromium runtime libs so zendriver
3
- # can operate in headless mode where allowed.
4
  FROM python:3.12-slim
5
 
6
- # runtime env
7
  ENV PYTHONDONTWRITEBYTECODE=1 \
8
  PYTHONUNBUFFERED=1 \
9
  PORT=7860 \
10
- ZD_HEADLESS=true \
11
- NO_INITIAL_FETCH=true
12
 
13
  WORKDIR /app
14
 
15
- # install system deps (chromium runtime libs + common utils)
16
  RUN apt-get update && apt-get install -y --no-install-recommends \
17
  ca-certificates \
18
  curl \
19
- gnupg \
20
  wget \
21
  unzip \
 
 
 
22
  fonts-liberation \
23
  libnss3 \
24
  libxss1 \
@@ -36,32 +35,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
36
  build-essential \
37
  && rm -rf /var/lib/apt/lists/*
38
 
39
- # Install Chromium (Debian's package name may vary across distros).
40
- # In many slim images the package is "chromium" or "chromium-browser".
41
- # Try chromium; if your target base differs, change accordingly.
42
  RUN apt-get update && apt-get install -y --no-install-recommends chromium \
43
  || true && rm -rf /var/lib/apt/lists/*
44
 
45
- # Safety: set CHROME_BIN to where Chromium usually is installed
46
  ENV CHROME_BIN=/usr/bin/chromium
47
 
48
- # copy requirements first (docker layer caching)
49
  COPY requirements.txt /app/requirements.txt
50
-
51
- # upgrade pip and install python deps
52
  RUN python -m pip install --upgrade pip setuptools wheel \
53
  && pip --no-cache-dir install -r /app/requirements.txt
54
 
55
- # copy app sources
56
  COPY . /app
57
 
58
- # make start script executable
59
  COPY start.sh /app/start.sh
60
  RUN chmod +x /app/start.sh
61
 
62
- # expose port
63
  EXPOSE ${PORT}
64
 
65
- # Start the server.
66
- # Use sh -c so ${PORT} expansion works in exec form.
67
  CMD ["sh", "-c", "/app/start.sh"]
 
1
+ # Dockerfile (run non-headless Chrome via Xvfb)
 
 
2
  FROM python:3.12-slim
3
 
 
4
  ENV PYTHONDONTWRITEBYTECODE=1 \
5
  PYTHONUNBUFFERED=1 \
6
  PORT=7860 \
7
+ ZD_HEADLESS=false \
8
+ NO_INITIAL_FETCH=false
9
 
10
  WORKDIR /app
11
 
12
+ # Install system deps including Xvfb and Chromium
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  ca-certificates \
15
  curl \
 
16
  wget \
17
  unzip \
18
+ xvfb \
19
+ dbus-x11 \
20
+ x11-utils \
21
  fonts-liberation \
22
  libnss3 \
23
  libxss1 \
 
35
  build-essential \
36
  && rm -rf /var/lib/apt/lists/*
37
 
38
+ # Install Chromium (Debian package). If that fails on some base images,
39
+ # adjust package name to chromium-browser.
 
40
  RUN apt-get update && apt-get install -y --no-install-recommends chromium \
41
  || true && rm -rf /var/lib/apt/lists/*
42
 
 
43
  ENV CHROME_BIN=/usr/bin/chromium
44
 
45
+ # python deps
46
  COPY requirements.txt /app/requirements.txt
 
 
47
  RUN python -m pip install --upgrade pip setuptools wheel \
48
  && pip --no-cache-dir install -r /app/requirements.txt
49
 
50
+ # app files
51
  COPY . /app
52
 
53
+ # start script
54
  COPY start.sh /app/start.sh
55
  RUN chmod +x /app/start.sh
56
 
 
57
  EXPOSE ${PORT}
58
 
 
 
59
  CMD ["sh", "-c", "/app/start.sh"]