From 6430246299542bd9205997cb49a418ae113b0f25 Mon Sep 17 00:00:00 2001 From: Odboy Date: Sat, 29 Nov 2025 21:34:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20tengine/python=20=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20build.sh=20=E9=A2=84=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E5=8C=85=EF=BC=8C=E7=A7=BB=E9=99=A4=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=20ADD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - proxy-tengine3、runtime-python3、tools-ansible:ADD 改成本地文件名, 源码包由 build.sh 先下载(已存在则复用),避免每次构建都拉外网且不受层缓存保护 - build.sh 加 shebang、set -euo pipefail,并 cd 到脚本所在目录,加可执行权限 - 三个目录新增 .dockerignore(不忽略源码包,ADD 源文件需在构建上下文内)与 .gitignore - runtime-jdk11/17/21 的 build.sh 已是预下载+解包流程,本次不动 --- image/proxy-tengine3/.dockerignore | 5 +++++ image/proxy-tengine3/.gitignore | 3 +++ image/proxy-tengine3/Dockerfile | 4 +++- image/proxy-tengine3/build.sh | 12 ++++++++++++ image/runtime-python3/.dockerignore | 5 +++++ image/runtime-python3/.gitignore | 3 +++ image/runtime-python3/Dockerfile | 4 +++- image/runtime-python3/build.sh | 12 ++++++++++++ image/tools-ansible/.dockerignore | 5 +++++ image/tools-ansible/.gitignore | 3 +++ image/tools-ansible/Dockerfile | 4 +++- image/tools-ansible/build.sh | 12 ++++++++++++ 12 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 image/proxy-tengine3/.dockerignore create mode 100644 image/proxy-tengine3/.gitignore create mode 100644 image/runtime-python3/.dockerignore create mode 100644 image/runtime-python3/.gitignore mode change 100644 => 100755 image/runtime-python3/build.sh create mode 100644 image/tools-ansible/.dockerignore create mode 100644 image/tools-ansible/.gitignore mode change 100644 => 100755 image/tools-ansible/build.sh diff --git a/image/proxy-tengine3/.dockerignore b/image/proxy-tengine3/.dockerignore new file mode 100644 index 0000000..f3487e9 --- /dev/null +++ b/image/proxy-tengine3/.dockerignore @@ -0,0 +1,5 @@ +# 由 build.sh 预下载的 tengine 源码包经 ADD 解压进镜像, +# ADD 的源文件必须在构建上下文内,因此 *.tar.gz 不能在这里忽略 +build.sh +.git/ +.DS_Store diff --git a/image/proxy-tengine3/.gitignore b/image/proxy-tengine3/.gitignore new file mode 100644 index 0000000..9a1bb28 --- /dev/null +++ b/image/proxy-tengine3/.gitignore @@ -0,0 +1,3 @@ +# 构建产物 / 本地缓存 +*.tar.gz +.DS_Store diff --git a/image/proxy-tengine3/Dockerfile b/image/proxy-tengine3/Dockerfile index f324b34..c446a2d 100644 --- a/image/proxy-tengine3/Dockerfile +++ b/image/proxy-tengine3/Dockerfile @@ -8,7 +8,9 @@ WORKDIR /home/admin # 使用自定义配置覆盖默认可映射的目录:conf/nginx.conf、conf/conf.d、conf/ssl COPY nginx.conf ${NGINX_HOME}/conf/nginx.conf # https://tengine.taobao.org/download/tengine-3.1.0.tar.gz -ADD https://tengine.taobao.org/download/tengine-${TENGINE_VERSION}.tar.gz ./ +# 由 build.sh 预先下载到本目录 +ADD tengine-${TENGINE_VERSION}.tar.gz ./ +# gcc/gcc-c++/make 用于编译 tengine;sysstat/net-tools 用于排障 RUN yum install \ gcc \ gcc-c++ \ diff --git a/image/proxy-tengine3/build.sh b/image/proxy-tengine3/build.sh index 6e6089f..1e5e2e4 100755 --- a/image/proxy-tengine3/build.sh +++ b/image/proxy-tengine3/build.sh @@ -1,3 +1,15 @@ +#!/usr/bin/env bash +# 先下载 tengine 源码包到当前目录,再基于本地文件构建镜像 +set -euo pipefail +cd "$(dirname "$0")" + +TENGINE=tengine-3.1.0.tar.gz +URL=https://tengine.taobao.org/download/tengine-3.1.0.tar.gz + +if [ ! -f "${TENGINE}" ]; then + curl -fL -o "${TENGINE}" "${URL}" +fi + IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:proxy-tengine3 docker build -t "${IMAGE}" . docker push "${IMAGE}" diff --git a/image/runtime-python3/.dockerignore b/image/runtime-python3/.dockerignore new file mode 100644 index 0000000..0499fef --- /dev/null +++ b/image/runtime-python3/.dockerignore @@ -0,0 +1,5 @@ +# 由 build.sh 预下载的 Python 源码包经 ADD 解压进镜像, +# ADD 的源文件必须在构建上下文内,因此 *.tgz 不能在这里忽略 +build.sh +.git/ +.DS_Store diff --git a/image/runtime-python3/.gitignore b/image/runtime-python3/.gitignore new file mode 100644 index 0000000..c1f73c5 --- /dev/null +++ b/image/runtime-python3/.gitignore @@ -0,0 +1,3 @@ +# 构建产物 / 本地缓存 +*.tgz +.DS_Store diff --git a/image/runtime-python3/Dockerfile b/image/runtime-python3/Dockerfile index 3ffbfc3..a982cec 100644 --- a/image/runtime-python3/Dockerfile +++ b/image/runtime-python3/Dockerfile @@ -4,7 +4,9 @@ ENV TimeZone=Asia/Shanghai ENV PYTHON_HOME=/usr/local/python3 ENV PATH="${PYTHON_HOME}/bin:$PATH" WORKDIR /home/admin -ADD https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz ./ +# https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz +# 由 build.sh 预先下载到本目录 +ADD Python-3.10.0.tgz ./ RUN yum install \ libffi-devel \ zlib-devel \ diff --git a/image/runtime-python3/build.sh b/image/runtime-python3/build.sh old mode 100644 new mode 100755 index bdfb524..e0af636 --- a/image/runtime-python3/build.sh +++ b/image/runtime-python3/build.sh @@ -1,3 +1,15 @@ +#!/usr/bin/env bash +# 先下载 Python 源码包到当前目录,再基于本地文件构建镜像 +set -euo pipefail +cd "$(dirname "$0")" + +PYTHON=Python-3.10.0.tgz +URL=https://www.python.org/ftp/python/3.10.0/${PYTHON} + +if [ ! -f "${PYTHON}" ]; then + curl -fL -o "${PYTHON}" "${URL}" +fi + IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:runtime-python3 docker build -t "${IMAGE}" . docker push "${IMAGE}" diff --git a/image/tools-ansible/.dockerignore b/image/tools-ansible/.dockerignore new file mode 100644 index 0000000..0499fef --- /dev/null +++ b/image/tools-ansible/.dockerignore @@ -0,0 +1,5 @@ +# 由 build.sh 预下载的 Python 源码包经 ADD 解压进镜像, +# ADD 的源文件必须在构建上下文内,因此 *.tgz 不能在这里忽略 +build.sh +.git/ +.DS_Store diff --git a/image/tools-ansible/.gitignore b/image/tools-ansible/.gitignore new file mode 100644 index 0000000..c1f73c5 --- /dev/null +++ b/image/tools-ansible/.gitignore @@ -0,0 +1,3 @@ +# 构建产物 / 本地缓存 +*.tgz +.DS_Store diff --git a/image/tools-ansible/Dockerfile b/image/tools-ansible/Dockerfile index dae7e8a..226ea8f 100644 --- a/image/tools-ansible/Dockerfile +++ b/image/tools-ansible/Dockerfile @@ -4,7 +4,9 @@ ENV TimeZone=Asia/Shanghai ENV PYTHON_HOME=/usr/local/python3 ENV PATH="${PYTHON_HOME}/bin:$PATH" WORKDIR /home/admin -ADD https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz ./ +# https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz +# 由 build.sh 预先下载到本目录 +ADD Python-3.10.0.tgz ./ RUN yum install \ libffi-devel \ zlib-devel \ diff --git a/image/tools-ansible/build.sh b/image/tools-ansible/build.sh old mode 100644 new mode 100755 index 61a199e..d366446 --- a/image/tools-ansible/build.sh +++ b/image/tools-ansible/build.sh @@ -1,3 +1,15 @@ +#!/usr/bin/env bash +# 先下载 Python 源码包到当前目录,再基于本地文件构建镜像 +set -euo pipefail +cd "$(dirname "$0")" + +PYTHON=Python-3.10.0.tgz +URL=https://www.python.org/ftp/python/3.10.0/${PYTHON} + +if [ ! -f "${PYTHON}" ]; then + curl -fL -o "${PYTHON}" "${URL}" +fi + IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:tools-ansible docker build -t "${IMAGE}" . docker push "${IMAGE}"