zhepama commited on
Commit
880fc32
·
verified ·
1 Parent(s): d0a46f8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -8
Dockerfile CHANGED
@@ -1,11 +1,20 @@
1
- # 步骤 1: 继承自 zhezzma/v2fly-core 镜像
2
  FROM zhezzma/v2fly-core:latest
3
 
4
- # 步骤 2: 将本地的 config.json 文件复制到镜像内的 /etc/v2ray/ 目录下
5
- COPY config.json /etc/v2ray/config.json
6
 
7
- # 步骤 3: 设置容器启动时要执行的命令
8
- # 基础镜像的 ENTRYPOINT 是 ["/usr/bin/v2ray"]
9
- # CMD 会作为参数追加到 ENTRYPOINT 后面
10
- # 最终执行的命令是: /usr/bin/v2ray run -config /etc/v2ray/config.json
11
- CMD ["run", "-config", "/etc/v2ray/config.json"]
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM zhezzma/v2fly-core:latest
2
 
3
+ # 安装envsubst工具(通常在gettext包中)
4
+ RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/*
5
 
6
+ # 复制配置模板
7
+ COPY config.json.template /etc/v2ray/config.json.template
8
+
9
+ # 创建启动脚本
10
+ RUN echo '#!/bin/bash\n\
11
+ if [ -z "$UUID" ]; then\n\
12
+ echo "错误: UUID环境变量未设置"\n\
13
+ exit 1\n\
14
+ fi\n\
15
+ envsubst < /etc/v2ray/config.json.template > /etc/v2ray/config.json\n\
16
+ exec /usr/bin/v2ray run -config /etc/v2ray/config.json' > /usr/local/bin/start.sh
17
+
18
+ RUN chmod +x /usr/local/bin/start.sh
19
+
20
+ ENTRYPOINT ["/usr/local/bin/start.sh"]