CSSSC / Dockerfile
AdarshJi's picture
Create Dockerfile
5cb2bb5 verified
raw
history blame
1.79 kB
# 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"]