gateway2/Dockerfile
2026-08-14 18:56:28 +08:00

80 lines
2.6 KiB
Docker

# gateway:v2 - GMSSL Gateway (Angie 1.11.8 + Tongsuo 8.4.0)
# Builds TongsuoSSL (static) and links Angie against it to provide SM2/SM3/SM4 GMSSL + NTLS support.
FROM ubuntu:24.04 AS build
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpcre2-dev \
zlib1g-dev \
libcrypt-dev \
perl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# ---- TongsuoSSL 8.4.0 ----
COPY 8.4.0.tar.gz /build/
RUN tar -xzf 8.4.0.tar.gz
WORKDIR /build/Tongsuo-8.4.0
RUN ./config --prefix=/opt/tongsuo-8.4.0 --libdir=lib64 no-shared no-zlib no-threads enable-ntls \
&& make -j$(nproc) \
&& make install_sw
# ---- Angie 1.11.8 (linked against Tongsuo, NTLS enabled) ----
WORKDIR /build
COPY angie-1.11.8.tar.gz /build/
COPY no-server-header-angie.patch /build/
RUN tar -xzf angie-1.11.8.tar.gz \
&& patch -p1 -d angie-Angie-1.11.8 < no-server-header-angie.patch
WORKDIR /build/angie-Angie-1.11.8
RUN ./configure \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-stream \
--with-stream_ssl_module \
--with-ntls \
--with-cc-opt="-I/opt/tongsuo-8.4.0/include" \
--with-ld-opt="-L/opt/tongsuo-8.4.0/lib64 -lssl -lcrypto -ldl -lpthread" \
&& make -j$(nproc) \
&& make install
# ---- Runtime ----
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libpcre2-8-0 \
zlib1g \
libcrypt1 \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /usr/local/nginx/conf/man/http \
/usr/local/nginx/conf/man/stream \
/usr/local/nginx/logs \
/app
COPY --from=build /usr/local/nginx /usr/local/nginx
# Rename the executable to "gateway"
RUN mv /usr/local/nginx/sbin/angie /usr/local/nginx/sbin/gateway
# Built-in main config (project root nginx.conf). Angie reads angie.conf by
# default, so install the project config under that name as well.
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
RUN cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/angie.conf
# The config directory is mounted by the test startup script to /usr/local/nginx/conf/man.
# Pre-create a placeholder http include so the server starts when nothing is mounted.
RUN printf '# empty\n' > /usr/local/nginx/conf/man/http/.keep \
&& printf '# empty\n' > /usr/local/nginx/conf/man/stream/.keep
EXPOSE 80 443 8443
CMD ["/usr/local/nginx/sbin/gateway", "-g", "daemon off;"]