feat : 魔改一下

This commit is contained in:
翟二远 2026-04-03 22:39:12 +08:00
parent 42c9f687fd
commit 3c4d7cefbe
3 changed files with 117 additions and 13 deletions

View file

@ -1,19 +1,31 @@
# 基础镜像(需要在云效中配置镜像加速器)
# 基础镜像 - Ubuntu 26.04
FROM jsessh-registry.cn-shanghai.cr.aliyuncs.com/base-images/python:latest
WORKDIR /app
# 2. 升级 pip 并配置镜像源
RUN pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 60 --retries 5 --trusted-host mirrors.aliyun.com
# 配置阿里云 Ubuntu 镜像源(加速 apt 下载)
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources 2>/dev/null || \
sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list 2>/dev/null || \
echo "sources.list not found, skipping"
# 安装系统依赖(Debian/Ubuntu 系统使用 apt-get)
# 升级 pip 并配置镜像源
RUN pip install --upgrade pip \
-i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 120 \
--retries 5 \
--trusted-host mirrors.aliyun.com
# 安装系统依赖和 Python 包
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
g++ \
make \
libc6-dev \
libffi-dev \
wget && \
libssl-dev \
wget \
ca-certificates && \
pip install --no-cache-dir \
-i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 120 \
@ -21,21 +33,23 @@ RUN apt-get update && \
--trusted-host mirrors.aliyun.com \
--extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple \
cisco-ai-skill-scanner && \
apt-get purge -y gcc libc6-dev libffi-dev && \
apt-get purge -y gcc g++ make libc6-dev libffi-dev libssl-dev && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 创建 app 用户和组(Debian/Ubuntu 语法)
RUN groupadd -r app && \
useradd -r -g app app && \
# 创建 app 用户和组(Ubuntu 语法)
RUN groupadd --system app && \
useradd --system --gid app --shell /bin/bash app && \
mkdir -p /tmp/skillhub-scans && \
chown app:app /tmp/skillhub-scans
chown -R app:app /tmp/skillhub-scans
USER app
EXPOSE 8000
HEALTHCHECK --interval=10s --timeout=3s \
CMD wget -qO- http://127.0.0.1:8000/health || exit 1
# 健康检查(使用 wget)
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8000/health || exit 1
CMD ["skill-scanner-api", "--host", "0.0.0.0", "--port", "8000"]

42
scanner/Dockerfile.debug Normal file
View file

@ -0,0 +1,42 @@
# 调试版 Dockerfile - 用于排查基础镜像问题
FROM jsessh-registry.cn-shanghai.cr.aliyuncs.com/base-images/python:latest
WORKDIR /app
# 显示系统信息
RUN echo "=== 系统信息 ===" && \
cat /etc/os-release && \
echo "" && \
echo "=== Python 版本 ===" && \
python --version && \
echo "" && \
echo "=== 包管理器检测 ===" && \
(which apt-get && echo "Found: apt-get") || echo "Not found: apt-get" && \
(which apk && echo "Found: apk") || echo "Not found: apk" && \
(which yum && echo "Found: yum") || echo "Not found: yum" && \
echo "" && \
echo "=== 已有工具 ===" && \
which gcc || echo "gcc: not found" && \
which make || echo "make: not found" && \
which wget || echo "wget: not found"
# 尝试最简单的 pip 安装(不安装系统依赖)
RUN pip install --upgrade pip \
-i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 120 \
--retries 5 \
--trusted-host mirrors.aliyun.com
RUN pip install --no-cache-dir \
-i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 120 \
--retries 5 \
--trusted-host mirrors.aliyun.com \
cisco-ai-skill-scanner || echo "Installation may have failed"
# 创建目录
RUN mkdir -p /tmp/skillhub-scans
EXPOSE 8000
CMD ["skill-scanner-api", "--host", "0.0.0.0", "--port", "8000"]

View file

@ -0,0 +1,48 @@
# 使用官方 Python Slim 镜像(Debian 基础)
FROM python:3.11-slim
WORKDIR /app
# 配置阿里云 Debian 镜像源(加速 apt-get)
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources || \
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
# 升级 pip
RUN pip install --upgrade pip \
-i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 120 \
--retries 5 \
--trusted-host mirrors.aliyun.com
# 安装系统依赖和 Python 包
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
libc6-dev \
libffi-dev \
wget && \
pip install --no-cache-dir \
-i https://mirrors.aliyun.com/pypi/simple/ \
--timeout 120 \
--retries 5 \
--trusted-host mirrors.aliyun.com \
--extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple \
cisco-ai-skill-scanner && \
apt-get purge -y gcc libc6-dev libffi-dev && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# 创建 app 用户和组
RUN groupadd -r app && \
useradd -r -g app app && \
mkdir -p /tmp/skillhub-scans && \
chown app:app /tmp/skillhub-scans
USER app
EXPOSE 8000
HEALTHCHECK --interval=10s --timeout=3s \
CMD wget -qO- http://127.0.0.1:8000/health || exit 1
CMD ["skill-scanner-api", "--host", "0.0.0.0", "--port", "8000"]