77 lines
2.0 KiB
Docker
77 lines
2.0 KiB
Docker
FROM ubuntu:24.04
|
|
|
|
# 备份并重建 sources.list - 使用阿里云镜像
|
|
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
|
|
echo "deb http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse" > /etc/apt/sources.list && \
|
|
echo "deb http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
|
|
echo "deb http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse" >> /etc/apt/sources.list && \
|
|
echo "deb http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse" >> /etc/apt/sources.list
|
|
|
|
# 删除可能存在的其他源文件
|
|
RUN rm -rf /etc/apt/sources.list.d/*
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
nginx \
|
|
curl \
|
|
wget \
|
|
libglib2.0-0 \
|
|
libnss3 \
|
|
libnspr4 \
|
|
libatk1.0-0 \
|
|
libatk-bridge2.0-0 \
|
|
libcups2 \
|
|
libdrm2 \
|
|
libdbus-1-3 \
|
|
libxkbcommon0 \
|
|
libxcomposite1 \
|
|
libxdamage1 \
|
|
libxfixes3 \
|
|
libxrandr2 \
|
|
libgbm1 \
|
|
libasound2t64 \
|
|
libpango-1.0-0 \
|
|
libcairo2 \
|
|
libatspi2.0-0 \
|
|
fonts-liberation \
|
|
libnss3-tools \
|
|
xvfb \
|
|
python3 \
|
|
python3-pip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 复制server文件
|
|
COPY ./server/* /app/server/
|
|
|
|
# 复制html文件
|
|
COPY ./html/ /app/html/
|
|
|
|
# 复制nginx配置文件
|
|
COPY ./nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# 安装Python依赖
|
|
RUN pip install --break-system-packages --proxy http://192.168.1.2:7890 -r /app/server/requirements.txt
|
|
|
|
# 设置Playwright使用国内镜像安装浏览器
|
|
ENV PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright
|
|
RUN playwright install chromium
|
|
|
|
# 创建下载目录和nginx运行所需目录
|
|
RUN mkdir -p /app/download /var/run/nginx
|
|
|
|
# 设置环境变量
|
|
ENV USER=admin
|
|
ENV PASSWORD=password
|
|
ENV SECRET_KEY='asd78yujncisa32r89'
|
|
|
|
# 设置卷
|
|
VOLUME ["/app/download"]
|
|
|
|
# 暴露端口
|
|
EXPOSE 80
|
|
|
|
# 启动命令
|
|
CMD service nginx start && cd /app/server && xvfb-run -a python3 api.py |