Update Dockerfile
Browse files- Dockerfile +27 -16
Dockerfile
CHANGED
@@ -1,16 +1,27 @@
|
|
1 |
-
FROM
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
RUN
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM alpine:latest
|
2 |
+
|
3 |
+
# 安装必要工具
|
4 |
+
RUN apk add --no-cache curl tar
|
5 |
+
|
6 |
+
# 创建非 root 用户
|
7 |
+
RUN addgroup -S singbox && adduser -S singbox -G singbox
|
8 |
+
|
9 |
+
# 创建工作目录
|
10 |
+
WORKDIR /app
|
11 |
+
|
12 |
+
# 下载并安装 sing-box(你也可以改成特定版本)
|
13 |
+
RUN curl -L https://github.com/SagerNet/sing-box/releases/latest/download/sing-box-linux-amd64.tar.gz \
|
14 |
+
-o sing-box.tar.gz && \
|
15 |
+
tar -xzf sing-box.tar.gz && \
|
16 |
+
mv sing-box /usr/local/bin/sing-box && \
|
17 |
+
chmod +x /usr/local/bin/sing-box && \
|
18 |
+
rm -f sing-box.tar.gz
|
19 |
+
|
20 |
+
# 拷贝配置文件(你需要在构建时提供 config.json)
|
21 |
+
COPY cf.json /app/config.json
|
22 |
+
|
23 |
+
# 切换到非 root 用户
|
24 |
+
USER singbox
|
25 |
+
|
26 |
+
# 设置启动命令
|
27 |
+
ENTRYPOINT ["sing-box", "run", "-c", "/app/config.json"]
|