zhepama commited on
Commit
d2ab933
·
verified ·
1 Parent(s): 43d2c44

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -23
Dockerfile CHANGED
@@ -1,27 +1,8 @@
1
- # 步骤 1: 继承自 zhezzma/v2fly-core 镜像
2
  FROM zhezzma/v2fly-core:latest
3
 
4
- # 步骤 2: 复制配置模板
5
  COPY config.json.template /etc/v2ray/config.json.template
6
 
7
- # 步骤 3: 直接在Dockerfile中创建启动脚本
8
- RUN echo '#!/bin/sh\n\
9
- if [ -z "$UUID" ]; then\n\
10
- echo "错误: UUID环境变量未设置"\n\
11
- exit 1\n\
12
- fi\n\
13
- echo "使用UUID: $UUID"\n\
14
- sed "s/env:UUID/$UUID/g" /etc/v2ray/config.json.template > /etc/v2ray/config.json\n\
15
- echo "生成的配置文件内容:"\n\
16
- cat /etc/v2ray/config.json\n\
17
- echo "启动V2Ray..."\n\
18
- exec /usr/bin/v2ray run -config /etc/v2ray/config.json' > /usr/local/bin/start.sh
19
-
20
- # 步骤 4: 给启动脚本执行权限
21
- RUN chmod +x /usr/local/bin/start.sh
22
-
23
- # 步骤 5: 验证文件是否存在(调试用)
24
- RUN ls -la /usr/local/bin/start.sh
25
-
26
- # 步骤 6: 设置容器启动命令
27
- ENTRYPOINT ["/usr/local/bin/start.sh"]
 
 
1
  FROM zhezzma/v2fly-core:latest
2
 
3
+ # 复制配置模板
4
  COPY config.json.template /etc/v2ray/config.json.template
5
 
6
+ # 直接使用CMD执行命令,避免创建脚本文件
7
+ ENTRYPOINT ["/bin/sh", "-c"]
8
+ CMD ["if [ -z \"$UUID\" ]; then echo '错误: UUID环境变量未设置'; exit 1; fi; echo \"使用UUID: $UUID\"; sed \"s/env:UUID/$UUID/g\" /etc/v2ray/config.json.template > /etc/v2ray/config.json; echo '生成的配置文件内容:'; cat /etc/v2ray/config.json; echo '启动V2Ray...'; exec /usr/bin/v2ray run -config /etc/v2ray/config.json"]