base依赖更新
This commit is contained in:
@@ -8,37 +8,105 @@ FROM eclipse-temurin:21-jre
|
|||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
ENV LANG=C.UTF-8 \
|
ENV LANG=C.UTF-8 \
|
||||||
LC_ALL=C.UTF-8 \
|
LC_ALL=C.UTF-8 \
|
||||||
TZ=Asia/Shanghai
|
TZ=Asia/Shanghai \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONIOENCODING=UTF-8 \
|
||||||
|
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||||
|
PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
|
||||||
|
|
||||||
|
# 设置阿里云Debian源和时区
|
||||||
|
RUN echo "deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib" > /etc/apt/sources.list && \
|
||||||
|
echo "deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo "deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo "deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo "deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo "deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo "deb https://mirrors.aliyun.com/debian-security/ bookworm-security main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo "deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main non-free non-free-firmware contrib" >> /etc/apt/sources.list && \
|
||||||
|
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid && \
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends gnupg2 ca-certificates
|
||||||
|
|
||||||
# 安装系统依赖和工具
|
# 安装系统依赖和工具
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y \
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||||
# Python环境
|
# Python环境
|
||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
python3-venv \
|
python3-venv \
|
||||||
|
python3-dev \
|
||||||
|
# 编译工具
|
||||||
|
build-essential \
|
||||||
# 网络和诊断工具
|
# 网络和诊断工具
|
||||||
netcat-traditional \
|
netcat-traditional \
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
# MySQL客户端
|
dnsutils \
|
||||||
|
iputils-ping \
|
||||||
|
# 系统工具
|
||||||
|
procps \
|
||||||
|
htop \
|
||||||
|
vim \
|
||||||
|
less \
|
||||||
|
# 数据库客户端
|
||||||
default-mysql-client \
|
default-mysql-client \
|
||||||
|
# 字体和图形库
|
||||||
|
fonts-liberation \
|
||||||
|
fonts-noto-color-emoji \
|
||||||
|
fonts-noto-cjk \
|
||||||
|
# Chrome依赖
|
||||||
|
libxss1 \
|
||||||
|
libx11-xcb1 \
|
||||||
|
libxcb1 \
|
||||||
|
libxcomposite1 \
|
||||||
|
libxcursor1 \
|
||||||
|
libxdamage1 \
|
||||||
|
libxi6 \
|
||||||
|
libxtst6 \
|
||||||
|
libnss3 \
|
||||||
|
libcups2 \
|
||||||
|
libxrandr2 \
|
||||||
|
libasound2 \
|
||||||
|
libatk1.0-0 \
|
||||||
|
libatk-bridge2.0-0 \
|
||||||
|
libpangocairo-1.0-0 \
|
||||||
|
libgtk-3-0 \
|
||||||
|
# 图片处理
|
||||||
|
libjpeg-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libpng-dev \
|
||||||
|
# 其他依赖
|
||||||
|
libffi-dev \
|
||||||
|
libssl-dev \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||||
|
&& echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
# 临时复制requirements.txt用于安装依赖
|
# 设置Python3为默认Python
|
||||||
|
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
|
||||||
|
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 配置pip使用清华源
|
||||||
|
RUN mkdir -p /etc/pip && \
|
||||||
|
echo "[global]" > /etc/pip/pip.conf && \
|
||||||
|
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /etc/pip/pip.conf && \
|
||||||
|
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /etc/pip/pip.conf
|
||||||
|
|
||||||
|
# 安装常用Python工具和爬虫依赖
|
||||||
COPY schoolNewsCrawler/requirements.txt /tmp/requirements.txt
|
COPY schoolNewsCrawler/requirements.txt /tmp/requirements.txt
|
||||||
|
|
||||||
# 安装Python爬虫依赖(一次性安装到基础镜像)
|
|
||||||
RUN echo "========================================" && \
|
RUN echo "========================================" && \
|
||||||
echo "安装Python爬虫依赖到基础镜像" && \
|
echo "安装Python爬虫依赖到基础镜像" && \
|
||||||
echo "========================================" && \
|
echo "========================================" && \
|
||||||
# 配置pip使用国内镜像源(清华源)
|
# 确保pip是最新版本
|
||||||
python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
|
python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
||||||
python3 -m pip --version && \
|
# 安装依赖
|
||||||
echo "" && \
|
|
||||||
# Python 3.12 引入了 PEP 668 规范,需要添加 --break-system-packages
|
|
||||||
python3 -m pip install --no-cache-dir --break-system-packages -r /tmp/requirements.txt && \
|
python3 -m pip install --no-cache-dir --break-system-packages -r /tmp/requirements.txt && \
|
||||||
|
# 清理缓存
|
||||||
|
python3 -m pip cache purge && \
|
||||||
|
# 验证安装
|
||||||
echo "" && \
|
echo "" && \
|
||||||
echo "✅ 爬虫依赖安装完成" && \
|
echo "✅ 爬虫依赖安装完成" && \
|
||||||
python3 -m pip list | grep -E "(beautifulsoup4|crawl4ai|selenium|pydantic|requests|loguru)" && \
|
python3 -m pip list | grep -E "(beautifulsoup4|crawl4ai|selenium|pydantic|requests|loguru)" && \
|
||||||
@@ -46,9 +114,12 @@ RUN echo "========================================" && \
|
|||||||
rm -f /tmp/requirements.txt
|
rm -f /tmp/requirements.txt
|
||||||
|
|
||||||
# 创建应用目录结构
|
# 创建应用目录结构
|
||||||
WORKDIR /app
|
|
||||||
RUN mkdir -p /app/config /app/logs /app/uploads /app/crawler
|
RUN mkdir -p /app/config /app/logs /app/uploads /app/crawler
|
||||||
|
|
||||||
|
# 健康检查
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:8080/actuator/health || exit 1
|
||||||
|
|
||||||
# 镜像元数据
|
# 镜像元数据
|
||||||
LABEL maintainer="School News Team" \
|
LABEL maintainer="School News Team" \
|
||||||
description="Base image for school-news backend service with Python dependencies" \
|
description="Base image for school-news backend service with Python dependencies" \
|
||||||
|
|||||||
Reference in New Issue
Block a user