Files
ssw__ipass/Dockerfile
T
admin db99ce1521 docs: 文档与注释系统性对齐插件化现状 + 清理前身实现引用
- readme §16 补 1.0.10-1.0.13 四条变更记录;§12.6 tag 表补 1.0.9-1.0.13
- readme §5 架构图更新为插件化结构(PLUGINS 注册表/四开关/四表)
- readme §11 补 api-proxies.json 数据模型小节;§8 管理台表格补 API 代理行
- readme/CLAUDE.md 测试断言数对齐 262(102+160);三个 JSON 改四个
- CLAUDE.md LLM 落点表改 crates/plugin-llm 路径;发版补 git push 前置教训
- 清理全部前身实现引用(readme 三处、CLAUDE.md 性能章节、util.rs 注释)
- PLUGIN_ARCHITECTURE.md 增补 1.0.13 sso 合流记录
2026-09-13 18:27:28 +08:00

97 lines
3.9 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-gateway —— 多阶段构建
#
# 这里必须自己编译 nginx。原因见 CLAUDE.md:ngx-rust 官方明确要求「针对生产上
# 真正要用的那份 nginx 源码 + 完全相同的 configure 参数」编译模块,否则 bindgen
# 看到的符号/API 与实际运行时不一致。
# ---------------------------------------------------------------------------
# 构建阶段:编译 nginx + 编译 Rust 动态模块
# ---------------------------------------------------------------------------
FROM rust:1.89-slim-bookworm AS builder
ARG NGINX_VERSION=1.30.4
# nginx 构建依赖 + bindgen 需要的 libclang + 下载工具
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpcre2-dev \
zlib1g-dev \
libssl-dev \
clang \
libclang-dev \
pkg-config \
curl \
ca-certificates \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
# 1) 拉取并编译 nginx(objs/ 里的头文件是 bindgen 的输入)
WORKDIR /src
RUN curl -fsSL "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx.tar.gz \
&& tar -xzf nginx.tar.gz \
&& rm nginx.tar.gz
WORKDIR /src/nginx-${NGINX_VERSION}
RUN ./configure \
--prefix=/usr/local/nginx \
--with-pcre \
--with-http_realip_module \
--with-http_ssl_module \
--without-http_gzip_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_autoindex_module \
--without-http_geo_module \
--without-http_split_clients_module \
--without-http_referer_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--without-http_grpc_module \
&& make -j"$(nproc)"
# 2) 编译 Rust 动态模块。只需 configure 过的源码树 + objs/,不必等 nginx 编完。
WORKDIR /build/rust
COPY rust/ ./
RUN NGINX_SOURCE_DIR="/src/nginx-${NGINX_VERSION}" \
NGINX_BUILD_DIR="/src/nginx-${NGINX_VERSION}/objs" \
cargo build --release
# ---------------------------------------------------------------------------
# 运行阶段:只带 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 \
&& rm -rf /var/lib/apt/lists/*
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_gateway.so /usr/local/nginx/modules/
# 配置 / 证书(正式证书随镜像分发;勿把镜像推到公共仓库)/ 管理台静态页 / 种子数据
# conf/nginx.conf 里的 include tls/*.conf 不递归,子目录内的供应商 .conf 不会被误加载
COPY conf/nginx.conf /usr/local/nginx/conf/nginx.conf
COPY conf/tls/ /usr/local/nginx/conf/tls/
COPY www/ /usr/local/nginx/www/
COPY deploy/data-seed/ /usr/local/nginx/data/
# 与旧版保持一致的工作目录约定,便于沿用现成的挂载与运维习惯
# data 必须对 worker(默认 nobody)可写:状态写穿 JSON 依赖它
# audit 同理:LLM 对话审计落盘目录(docs/llm/AUDIT_LOG.md),生产建议挂宿主机卷
RUN mkdir -p /usr/local/nginx/conf /usr/local/nginx/www /usr/local/nginx/data /usr/local/nginx/audit /usr/local/nginx/logs \
&& chown -R nobody:nogroup /usr/local/nginx/data /usr/local/nginx/audit \
&& ln -sf /dev/stdout /usr/local/nginx/logs/access.log \
&& ln -sf /dev/stderr /usr/local/nginx/logs/error.log
WORKDIR /usr/local/nginx
EXPOSE 80 18098 443
STOPSIGNAL SIGQUIT
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]