Files
sso/deploy/Dockerfile
T
adminandClaude Code c3689d501e chore: SSO-only 精简版初始提交(从 ipass-all 派生)
**影响**:新建独立仓 ipass-sso 作为 ipass-all 的 SSO-only 精简发行版——
剔除了 domain / llm / apix / cache / waf 5 个插件及对应的 nginx location
与 LLM/域名数据面 server,PLUGINS 数组只剩 sso + core,单 .so 体积与编
译时间同步下降。镜像名沿用 ssw188/nginx(同 repo 加 tag),新 tag
`ipass-sso-v0.6.0`,K8s 部署在 wuguirong ns NodePort 30082,与生产
ipass-all-v0.5.2 (30083/30084/30085) 并存互不干扰。

**改动**:
- `rust/Cargo.toml` + `rust/gateway/Cargo.toml`:删 5 个 plugin path 依赖,
  package/lib 重命名为 `ipass-sso-gateway` / `libipass_sso_gateway`
- `rust/gateway/src/lib.rs`:PLUGINS 只剩 `&SsoPlugin` + `&CorePlugin`;
  GatewayExt 4 个方法改为 no-op / 返回默认值(无 domain/llm 装饰);
  ModuleConfig 只剩 api + iap 两个开关;NGX_HTTP_COMMANDS 数组 11→4 条;
  init_process / exit_process 删 llm audit / stats persist 调用;
  state_zone_init 删 domain/upstreams/apix 的预装载
- `rust/gateway/src/api.rs`:删除(h_admin_trend 依赖 llm + apix)
- `deploy/nginx.conf`:删 server 498 (LLM) + server 565 (域名);
  主 server 删 `/apix/` `/apixp/` `/_apix_probe/` 等 7 个 location;
  删 6 条 `proxy_cache_path` 与 8 个 cache location;删 `ipass_audit_dir` 指令
- `deploy/Dockerfile`:删 5 个 plugin named context 的 COPY 块;
  .so 文件名改 `libipass_sso_gateway.so`
- `deploy/build.sh`:TAG 默认 `ipass-sso-v0.6.0`;
  5 个 plugin build-context 删除;删 collect-legacy.sh 调用
- `data-seed/plugin-config.json`:只保留 `sso` 一个 plugin
- `scripts/collect-plugin-dist.sh`:PLUGINS 默认值改 `sso`
- `scripts/container-entrypoint.sh`:删 cache/audit 目录预创建
- `deploy/legacy/` `tests/` `docs/` `deploy/custom/` `deploy/compose.yml`:
  精简版不需要,删除
- `deploy/k8s/ipass-sso.yaml`:新建精简版 K8s manifest
  (NodePort 30082 单端口;replicas=1;同 10106 准入 + nginx-data PVC sso/ subPath;
  探针用 `/admin/` try_files 兜底,与 ipass-all 同款止血方案)

**设计**:保留 ipass-core("core 是网关身份底座,永不跳过")+ ipass-plugin-sso,
其余插件整链剥离;不再维护 ssow/ssw 时代的多插件装配文档。剔除 ipass_audit_dir
是因为精简版没有 LLM 对话审计,剔除 proxy_cache_path 同理。K8s 部署沿用
nginx-data PVC + subPath 隔离模式(sso/ 与 ipass-all/ 互不干扰)。

**已知约束**:精简版仍是单进程共享内存,pod 重启使所有管理员/用户会话失效
(与 ipass-all 同款代价)。精简版不带单元/E2E 测试,老管理台 iframe 集成
也未引入。

Co-Authored-By: Claude Code <[email protected]>
2026-09-30 12:01:38 +08:00

122 lines
5.8 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ipass-sso 网关镜像 —— 多阶段构建(复用 rust-nginx-base)
#
# 从 ipass-all 派生的精简发行版:只装 ipass-core + ipass-plugin-sso(2 个 named
# context),gateway 装配层把内核 + sso 编进单个 libipass_sso_gateway.so。
#
# 设计:
# - builder 阶段:FROM crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:1.30.4-rust-1.89
# base 已含 rust 1.89 + 已 configure/make 的 nginx 1.30.4 + pcre 8.45 + 编译链,
# 这里只跑 cargo build
# - runtime 阶段:debian:bookworm-slim,只带 nginx 二进制 + 模块 + 静态资源
#
# 构建命令(context = 本仓根;2 个 named context 缺一不可):
# bash scripts/collect-plugin-dist.sh # 前置:收集壳 + sso 管理页 dist
# docker build \
# --build-context ipass-core=../ipass-core \
# --build-context ipass-plugin-sso=../ipass-plugin-sso \
# -t crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:ipass-sso-v0.6.0 .
#
# named context 落位约定:COPY 到 /ipass-core、/ipass-plugin-sso —— builder 的
# WORKDIR 是 /build,rust/Cargo.toml 里 `../../ipass-core/...` 与插件自己的
# `../ipass-core/...` 等 path 依赖按宿主机「同级目录」布局原样解析。
# ⚠️ 每个插件仓只 COPY 编译所需子集(Cargo.toml/src/vendor/rules),
# 避开几百 MB 的 target/ 与 data/。
#
# 升级 nginx/rust 版本时:先跑 ipass-sso/deploy/build-base-image.sh 推新 base,
# 再 bump 此处 FROM 的 tag。
# syntax=docker/dockerfile:1.7
ARG BASE_TAG=1.30.4-rust-1.89
# ===========================================================================
# builder: 复用 rust-nginx-base + Rust 模块编译(nginx 二进制 base 里已 make 好)
# ===========================================================================
FROM crpi-yscq976uwza88qap.cn-shenzhen.personal.cr.aliyuncs.com/ssw188/nginx:${BASE_TAG} AS builder
WORKDIR /build
# 内核(含 vendored ngx-rust 与 pcre 路径依赖的源码树约定)
COPY --from=ipass-core /rust/Cargo.toml /rust/Cargo.lock /ipass-core/rust/
COPY --from=ipass-core /rust/crates/ /ipass-core/rust/crates/
COPY --from=ipass-core /rust/vendor/ /ipass-core/rust/vendor/
# SSO 插件 crate(只 1 个 plugin)
COPY --from=ipass-plugin-sso /Cargo.toml /Cargo.lock /ipass-plugin-sso/
COPY --from=ipass-plugin-sso /src/ /ipass-plugin-sso/src/
# 装配层(本仓)
COPY rust/ /build/rust/
# cargo 国内镜像源(rsproxy):base 镜像没带 cargo 配置,直连 crates.io
# 在国内网络下会长时间悬挂在下载阶段(ipass-sso 同款)。
RUN printf '[source.crates-io]\nreplace-with = "rsproxy-sparse"\n\n[source.rsproxy-sparse]\nregistry = "sparse+https://rsproxy.cn/index/"\n\n[net]\ngit-fetch-with-cli = true\n' \
> "${CARGO_HOME:-/usr/local/cargo}/config.toml"
WORKDIR /build/rust
# nginx 源码树路径与 base 镜像内一致(bindgen 从 objs/Makefile 抽 -I)
ENV NGINX_SOURCE_DIR=/src/nginx-1.30.4
ENV NGINX_BUILD_DIR=/src/nginx-1.30.4/objs
ENV CARGO_TARGET_DIR=/build/rust/target
RUN cargo build --release 2>&1 | tail -15
# ===========================================================================
# runtime: 极简镜像,只带 nginx 二进制 + 模块 + 静态资源 + 种子数据
# ===========================================================================
FROM debian:bookworm-slim AS runtime
ARG NGINX_VERSION=1.30.4
RUN apt-get update && apt-get install -y --no-install-recommends \
libpcre2-8-0 \
zlib1g \
libssl3 \
ca-certificates \
curl \
tzdata \
python3 \
&& rm -rf /var/lib/apt/lists/*
# 与 iPass 一致:TZ=Asia/Shanghai,util::day_id 按上海时区 0:00 切日(趋势/用量口径)
ENV TZ=Asia/Shanghai
COPY --from=builder /src/nginx-${NGINX_VERSION}/objs/nginx /usr/local/nginx/sbin/nginx
COPY --from=builder /src/nginx-${NGINX_VERSION}/conf/mime.types /usr/local/nginx/conf/mime.types
COPY --from=builder /build/rust/target/release/libipass_sso_gateway.so /usr/local/nginx/modules/
# 生产配置(deploy/nginx.conf:全插件 location 布局 + 非 root 适配)
COPY deploy/nginx.conf /usr/local/nginx/conf/nginx.conf
# 管理台前端(Ruling 16):构建前由 scripts/collect-plugin-dist.sh 把
# ipass-core 壳收集进 deploy/shell、各插件 dist 收集进 deploy/static-plugins
COPY deploy/shell/ /usr/local/nginx/www/
COPY deploy/static-plugins/ /usr/local/nginx/static-plugins/
# 装配层自定义页清单(core 壳 boot 时拉取并注册为自定义页;其他装配可没有)
COPY deploy/custom/ /usr/local/nginx/static-custom/
# 老管理台多页应用(collect-legacy.sh 从各仓提取,壳内 iframe 原样集成)
COPY deploy/legacy/ /usr/local/nginx/www/legacy/
# 种子数据(admin/alice + OAuth 接入方 + 插件启停注册表)
COPY data-seed/ /usr/local/nginx/data-seed/
# 目录与属主:k8s 租户准入强制 runAsUser=10106,data 与 /tmp/nginx 必须
# 预先可写(挂 PVC 后属主由 fsGroup=10106 接管,chown 只保无卷直跑)。
# 日志走 /dev/std* 符号链接(kubectl logs 直接可见)。
RUN mkdir -p /usr/local/nginx/data /usr/local/nginx/logs /tmp/nginx \
&& chown -R 10106:10106 /usr/local/nginx/data /tmp/nginx \
&& ln -sf /dev/stdout /usr/local/nginx/logs/access.log \
&& ln -sf /dev/stderr /usr/local/nginx/logs/error.log
# 首次启动播种 admin/alice + 渲染配置 + 起 nginx
COPY scripts/container-entrypoint.sh /usr/local/nginx/scripts/container-entrypoint.sh
COPY scripts/seed-data.sh /usr/local/nginx/scripts/seed-data.sh
RUN chmod +x /usr/local/nginx/scripts/container-entrypoint.sh /usr/local/nginx/scripts/seed-data.sh
WORKDIR /usr/local/nginx
EXPOSE 18098 18099
STOPSIGNAL SIGQUIT
ENTRYPOINT ["/usr/local/nginx/scripts/container-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]