Files
SamWaf/Dockerfile
T
samwaf 8f3ad4d9c8 fix:docker iptable bug
#IK0319
2026-07-14 16:02:19 +08:00

44 lines
1.4 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.
FROM alpine:latest
LABEL authors="samwaf"
# 设置工作目录
WORKDIR /app
# 设置默认时区为上海
ENV TZ=Asia/Shanghai
# 更新并安装时区数据
# iptables 供“防火墙IP封禁”功能使用(提供 iptables / iptables-save
# 注意:容器还需以 --cap-add=NET_ADMIN --network host 启动,规则才能对宿主机流量生效
RUN apk update && \
apk add --no-cache tzdata iptables && \
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo "${TZ}" > /etc/timezone
# 定义构建参数(由 Buildx 提供)
ARG TARGETARCH
# 根据架构动态复制对应的二进制文件
# 只包含当前架构的文件
ADD dist/samwaf_linux_linux_amd64_v1/SamWafLinux64 /app/SamWafLinux64.amd64
ADD dist/samwaf_linux_arm64_linux_arm64/SamWafLinuxArm64 /app/SamWafLinux64.arm64
# 动态选择文件
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
mv /app/SamWafLinux64.amd64 /app/SamWafLinux64 && rm -f /app/SamWafLinux64.arm64; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
mv /app/SamWafLinux64.arm64 /app/SamWafLinux64 && rm -f /app/SamWafLinux64.amd64; \
else \
echo "Unsupported architecture: ${TARGETARCH}" && exit 1; \
fi
# 设置执行权限
RUN chmod +x /app/SamWafLinux64
# 挂载 conf, data, logs 和 ssl 目录
VOLUME ["/app/conf", "/app/data", "/app/logs", "/app/ssl"]
# 暴露端口
EXPOSE 26666 80 443
# 设置默认命令来启动 SamWafLinux64
CMD ["./SamWafLinux64"]