Angie Docker 镜像#

要在 Docker 容器中运行 Angie,请使用我们注册表中的镜像:docker.angie.software。它们基于我们的 二进制包 和几个操作系统的官方基础镜像构建。

最小镜像#

  • angie:minimal: 基于 Alpine 3.21 的版本 1.8.2。

  • angie:<VERSION>-minimal: 基于 Alpine 3.21 的指定版本。

这些镜像仅包含 angie 包。

模板化镜像#

  • angie:templated: 基于 Alpine 3.21 的版本 1.8.2。

  • angie:<VERSION>-templated: 基于 Alpine 3.21 的指定版本。

这些镜像设置以下环境变量:

ENV ANGIE_BINARY="angie"
ENV ANGIE_CONFIG_TEMPLATE="/etc/angie/angie.conf.t"
ENV ANGIE_ERROR_LOG_SEVERITY="notice"
ENV ANGIE_FEATURE_RELOAD="on"
ENV ANGIE_FEATURE_TEMPLATE="on"
ENV ANGIE_LOAD_MODULES=""
ENV ANGIE_PID_FILE="/run/angie/angie.pid"
ENV ANGIE_WORKER_CONNECTIONS="65536"
ENV ANGIE_WORKER_RLIMIT_NOFILE="65536"

这些变量可以用于自定义容器的行为:

  • ANGIE_BINARY: 允许运行 调试二进制文件

  • ANGIE_ERROR_LOG_SEVERITY: 设置顶级 错误日志 的严重性级别。

  • ANGIE_LOAD_MODULES: 加载任何可用模块(所有模块均包含在镜像中)。指定 一个不带空格的逗号分隔模块名称列表。

  • ANGIE_PID_FILE: 指定 PID 文件的自定义位置。

  • ANGIE_FEATURE_TEMPLATE: 在容器启动时执行 gomplate,并设置 --input-dir /etc/angie/templates--output-dir /etc/angie 以生成 Angie 配置

  • ANGIE_FEATURE_RELOAD: 启用对 SIGHUPSIGQUITSIGTERM 信号的处理。

示例#

模板化镜像中的配置大致使用这些变量:

...
{{- if has $modules "zstd"}}
# package: angie-module-zstd
load_module modules/ngx_http_zstd_filter_module.so;
load_module modules/ngx_http_zstd_static_module.so;
{{end}}

user  angie;
worker_processes  auto;
worker_rlimit_nofile {{.Env.ANGIE_WORKER_RLIMIT_NOFILE}};

error_log  /var/log/angie/error.log {{.Env.ANGIE_ERROR_LOG_SEVERITY}};
pid        {{.Env.ANGIE_PID_FILE}};

events {
    worker_connections  {{.Env.ANGIE_WORKER_CONNECTIONS}};
}

http {
    include       /etc/angie/mime.types;
    default_type  application/octet-stream;

    log_format  main  ...

运行带有 shell 访问的容器:

$ docker run -it --pull always --rm --entrypoint=sh \
  docker.angie.software/angie:templated

使用自定义工作连接数和特定模块加载运行 Angie (命令 angie -T 将显示完整配置):

$ docker run -it --rm -e ANGIE_WORKER_CONNECTIONS=4 \
  -e ANGIE_LOAD_MODULES="auth-jwt,vod" \
  docker.angie.software/angie:templated angie -T

启动一个具有自定义名称和加载模块的容器:

$ docker run -it --rm --name angie-test \
  -e ANGIE_WORKER_CONNECTIONS=4 \
  -e ANGIE_LOAD_MODULES="auth-jwt,vod" \
  docker.angie.software/angie:templated

重新加载正在运行的容器的配置:

$ docker kill -s HUP angie-test

带有额外模块的镜像#

  • angie:latest: 基于 Alpine 3.21 的版本 1.8.2。

  • angie:<VERSION>angie:<VERSION>-alpine: 基于 Alpine 3.21 的指定版本。

  • angie:<VERSION>-debian: 基于 Debian 12 的指定版本。

  • angie:<VERSION>-rocky: 基于 Rocky Linux 9 的指定版本。

  • angie:<VERSION>-ubuntu: 基于 Ubuntu 24.04 LTS 的指定版本。

这些包含以下 (如果它们为该镜像构建时的 Angie 版本 发布):

包列表
  • angie-console-light

  • angie-module-auth-jwt

  • angie-module-auth-spnego

  • angie-module-brotli

  • angie-module-cache-purge

  • angie-module-dav-ext

  • angie-module-dynamic-limit-req

  • angie-module-echo

  • angie-module-enhanced-memcached

  • angie-module-eval

  • angie-module-geoip2

  • angie-module-headers-more

  • angie-module-http-auth-radius

  • angie-module-image-filter

  • angie-module-keyval

  • angie-module-lua

  • angie-module-modsecurity

  • angie-module-ndk

  • angie-module-njs

  • angie-module-opentracing

  • angie-module-otel

  • angie-module-perl

  • angie-module-postgres

  • angie-module-redis2

  • angie-module-rtmp

  • angie-module-set-misc

  • angie-module-subs

  • angie-module-testcookie

  • angie-module-upload

  • angie-module-vod

  • angie-module-vts

  • angie-module-wasm

  • angie-module-wasmtime

  • angie-module-xslt

  • angie-module-zip

  • angie-module-zstd

运行#

要在 8080 端口启动一个包含 Angie 的容器, 启用对 /var/www/ 静态文件目录 和当前工作目录中的 angie.conf 文件的只读访问:

$ docker run --rm --name angie -v /var/www:/usr/share/angie/html:ro \
    -v $(pwd)/angie.conf:/etc/angie/angie.conf:ro -p 8080:80 -d docker.angie.software/angie:latest

$ curl -I localhost:8080

    HTTP/1.1 200 OK
    Server: Angie/1.8.2
    Date: Thu, 13 Feb 2025 10:42:54 GMT
    Content-Type: text/html
    Content-Length: 543
    Last-Modified: Thu, 13 Feb 2025 09:12:23 GMT
    Connection: keep-alive
    ETag: "64c3ccc7-21f"
    Accept-Ranges: bytes

这样的设置可以用于本地开发和配置。

自定义镜像#

此外,您还可以基于受支持的发行版构建自己的镜像, 添加带有 源代码 的 Angie 层。 以下是两个 Dockerfile 示例:

Debian,使用 Angie 包#
FROM debian:12

LABEL org.opencontainers.image.authors="Release Engineering Team <devops@tech.wbsrv.ru>"

ARG DEBIAN_FRONTEND=noninteractive

RUN set -x \
     && apt-get update \
     && apt-get install --no-install-recommends --no-install-suggests -y \
          ca-certificates curl \
     && curl -o /etc/apt/trusted.gpg.d/angie-signing.gpg \
          https://angie.software/keys/angie-signing.gpg \
     && echo "deb https://download.angie.software/angie/$(. /etc/os-release && echo \"$ID/$VERSION_ID $VERSION_CODENAME\") main" \
          > /etc/apt/sources.list.d/angie.list \
     && apt-get update \
     && apt-get install --no-install-recommends --no-install-suggests -y \
          angie angie-module-geoip2 angie-module-njs \
     && rm -Rf /var/lib/apt/lists \
          /etc/apt/sources.list.d/angie.list \
          /etc/apt/trusted.gpg.d/angie-signing.gpg \
     && ln -sf /dev/stdout /var/log/angie/access.log \
     && ln -sf /dev/stderr /var/log/angie/error.log

EXPOSE 80

CMD ["angie", "-g", "daemon off;"]
Alpine,使用 Angie 包#
FROM alpine:3.19

LABEL org.opencontainers.image.authors="Release Engineering Team <devops@tech.wbsrv.ru>"

RUN set -x \
     && apk add --no-cache ca-certificates curl \
     && curl -o /etc/apk/keys/angie-signing.rsa https://angie.software/keys/angie-signing.rsa \
     && echo "https://download.angie.software/angie/alpine/v$(egrep -o \
          '[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \
     && apk add --no-cache angie angie-module-geoip2 angie-module-njs \
     && rm /etc/apk/keys/angie-signing.rsa \
     && ln -sf /dev/stdout /var/log/angie/access.log \
     && ln -sf /dev/stderr /var/log/angie/error.log

EXPOSE 80

CMD ["angie", "-g", "daemon off;"]

要在 Dockerfile 的目录中构建 myangie 镜像, 并以与上述相同的方式启动容器:

$ docker build -t myangie .
$ docker run --rm --name myangie -v /var/www:/usr/share/angie/html:ro \
    -v $(pwd)/angie.conf:/etc/angie/angie.conf:ro -p 8080:80 -d myangie