mirror of
https://github.com/zhinianboke/xianyu-auto-reply.git
synced 2025-08-30 01:27:35 +08:00
124 lines
3.6 KiB
Docker
124 lines
3.6 KiB
Docker
# 使用Python 3.11作为基础镜像
|
||
FROM python:3.11-slim
|
||
|
||
# 设置标签信息
|
||
LABEL maintainer="zhinianboke"
|
||
LABEL version="2.1.0"
|
||
LABEL description="闲鱼自动回复系统 - 企业级多用户版本,支持自动发货和免拼发货"
|
||
LABEL repository="https://github.com/zhinianboke/xianyu-auto-reply"
|
||
LABEL license="仅供学习使用,禁止商业用途"
|
||
LABEL author="zhinianboke"
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置环境变量
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV PYTHONDONTWRITEBYTECODE=1
|
||
ENV TZ=Asia/Shanghai
|
||
ENV DOCKER_ENV=true
|
||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0
|
||
ENV DEBIAN_FRONTEND=noninteractive
|
||
|
||
# 安装系统依赖(包括Playwright浏览器依赖)
|
||
RUN apt-get update && \
|
||
apt-get install -y --no-install-recommends \
|
||
# 基础工具
|
||
nodejs \
|
||
npm \
|
||
tzdata \
|
||
curl \
|
||
ca-certificates \
|
||
# 图像处理依赖
|
||
libjpeg-dev \
|
||
libpng-dev \
|
||
libfreetype6-dev \
|
||
fonts-dejavu-core \
|
||
fonts-liberation \
|
||
# Playwright浏览器依赖
|
||
libnss3 \
|
||
libnspr4 \
|
||
libatk-bridge2.0-0 \
|
||
libdrm2 \
|
||
libxkbcommon0 \
|
||
libxcomposite1 \
|
||
libxdamage1 \
|
||
libxrandr2 \
|
||
libgbm1 \
|
||
libxss1 \
|
||
libasound2 \
|
||
libatspi2.0-0 \
|
||
libgtk-3-0 \
|
||
libxcursor1 \
|
||
libxi6 \
|
||
libxrender1 \
|
||
libxext6 \
|
||
libx11-6 \
|
||
libxft2 \
|
||
libxinerama1 \
|
||
libxtst6 \
|
||
libappindicator3-1 \
|
||
libx11-xcb1 \
|
||
libxfixes3 \
|
||
xdg-utils \
|
||
# 尝试安装 gdk-pixbuf 包(兼容不同版本)
|
||
&& (apt-get install -y --no-install-recommends libgdk-pixbuf-2.0-0 || \
|
||
apt-get install -y --no-install-recommends libgdk-pixbuf2.0-0 || \
|
||
echo "Warning: Could not install gdk-pixbuf package") \
|
||
&& apt-get clean \
|
||
&& rm -rf /var/lib/apt/lists/* \
|
||
&& rm -rf /tmp/* \
|
||
&& rm -rf /var/tmp/*
|
||
|
||
# 设置时区
|
||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||
|
||
# 验证Node.js安装并设置环境变量
|
||
RUN node --version && npm --version
|
||
ENV NODE_PATH=/usr/lib/node_modules
|
||
|
||
# 复制requirements.txt并安装Python依赖
|
||
COPY requirements.txt .
|
||
RUN pip install --no-cache-dir --upgrade pip && \
|
||
pip install --no-cache-dir -r requirements.txt
|
||
|
||
# 复制自定义依赖安装脚本
|
||
COPY install-playwright-deps.sh /tmp/install-playwright-deps.sh
|
||
RUN chmod +x /tmp/install-playwright-deps.sh
|
||
|
||
# 复制项目文件
|
||
COPY . .
|
||
|
||
# 复制 Playwright 检查脚本
|
||
COPY playwright_checker.py /app/playwright_checker.py
|
||
|
||
# 安装Playwright浏览器(必须在复制项目文件之后)
|
||
RUN playwright install chromium
|
||
|
||
# 使用自定义脚本安装 Playwright 依赖
|
||
RUN /tmp/install-playwright-deps.sh || echo "Warning: Some Playwright dependencies could not be installed, but this may not affect functionality"
|
||
|
||
# 清理安装脚本
|
||
RUN rm -f /tmp/install-playwright-deps.sh
|
||
|
||
# 创建必要的目录并设置权限
|
||
RUN mkdir -p /app/logs /app/data /app/backups /app/static/uploads/images && \
|
||
chmod 777 /app/logs /app/data /app/backups /app/static/uploads /app/static/uploads/images
|
||
|
||
# 注意: 为了简化权限问题,使用root用户运行
|
||
# 在生产环境中,建议配置适当的用户映射
|
||
|
||
# 暴露端口
|
||
EXPOSE 8080
|
||
|
||
# 健康检查
|
||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||
CMD curl -f http://localhost:8080/health || exit 1
|
||
|
||
# 复制启动脚本
|
||
COPY entrypoint.sh /app/entrypoint.sh
|
||
RUN chmod +x /app/entrypoint.sh
|
||
|
||
# 启动命令
|
||
CMD ["/app/entrypoint.sh"] |