P2P / Dockerfile
ASC8384's picture
try
2a97c22
FROM python:3.10-slim
# 安装系统依赖 (只保留确实存在的包)
RUN apt-get update && apt-get install -y \
wget \
gnupg \
ca-certificates \
fonts-liberation \
libasound2 \
libasound2-dev \
libatk-bridge2.0-0 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc-s1 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libnss3-dev \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
lsb-release \
xdg-utils \
# 基础多媒体支持
libgstreamer1.0-0 \
libgstreamer-plugins-base1.0-0 \
# 图形库
libatomic1 \
libxslt1.1 \
libvpx7 \
libevent-2.1-7 \
libopus0 \
&& rm -rf /var/lib/apt/lists/*
# WORKDIR /app
WORKDIR /code
# RUN pip install --no-cache-dir -r requirements.txt
# Install Python dependencies
RUN pip install --upgrade pip
COPY requirements.txt .
RUN pip install -r requirements.txt
# Install Playwright and download the required browsers
RUN playwright install --with-deps
# Create and switch to a non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Ensure Playwright browsers are installed for the non-root user
RUN playwright install
# 暴露端口
EXPOSE 7860
COPY --chown=user:user . /code
CMD ["sh", "-c", "python init_playwright.py && python app.py"]
# CMD ["python", "app.py"]