Files
fscarmen-sing-box/Dockerfile
T
fscarmen 8ebd2d54f6 Switched the image from supervisord to s6-overlay because it provides a much smaller memory footprint.
s6-overlay vs supervisord — Memory Footprint Comparison

s6-overlay:
Uses only 1–2 MB of RAM. Its service processes typically consume around 200 KB RSS each.
Extremely lightweight, written in C, minimal overhead.

supervisord:
Consumes roughly 10–15 MB of RAM in real-world usage.
Implemented in Python, so it naturally has a higher baseline memory footprint (≈8–10× s6-overlay).
2025-11-16 01:38:44 +00:00

42 lines
1.1 KiB
Docker

# 构建阶段
FROM alpine:latest AS builder
ARG TARGETARCH
ENV ARCH=$TARGETARCH
# 安装构建依赖
RUN set -ex &&\
apk add --no-cache wget xz
# 下载并解压 s6-overlay
RUN set -ex &&\
case "$ARCH" in \
amd64) S6_ARCH=x86_64 ;; \
arm64) S6_ARCH=aarch64 ;; \
armv7) S6_ARCH=armhf ;; \
*) S6_ARCH=x86_64 ;; \
esac &&\
wget -qO- https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-noarch.tar.xz | tar -C / -Jx &&\
wget -qO- https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-$S6_ARCH.tar.xz | tar -C / -Jx
# 运行阶段
FROM alpine:latest
ARG TARGETARCH
ENV ARCH=$TARGETARCH
# 设置工作目录
WORKDIR /sing-box
# 从构建阶段复制 s6-overlay 文件
COPY --from=builder / /
# 复制初始化脚本
COPY docker_init.sh /sing-box/init.sh
# 安装运行时依赖并生成证书
RUN set -ex &&\
apk add --no-cache wget nginx bash openssl &&\
mkdir -p /sing-box/cert /sing-box/conf /sing-box/subscribe /sing-box/logs &&\
chmod +x /sing-box/init.sh &&\
rm -rf /var/cache/apk/*
CMD [ "./init.sh" ]