arronlx commited on
Commit
32048e2
·
verified ·
1 Parent(s): ef9cc06

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -12
Dockerfile CHANGED
@@ -1,17 +1,29 @@
1
  FROM ghcr.io/senshinya/moontv:latest
2
 
3
- # 安装curl(如果基础镜像中没有)
4
- RUN apt-get update && apt-get install -y curl || apk add --no-cache curl
5
 
6
- # 从指定URL下载config.json(使用环境变量配置URL)
7
- ARG CONFIG_URL
8
- ENV CONFIG_URL=${CONFIG_URL}
9
 
10
- RUN if [ -n "$CONFIG_URL" ]; then \
11
- curl -o /app/config.json "$CONFIG_URL" || echo "警告: 无法下载配置文件,使用默认配置"; \
12
- else \
13
- echo "错误: 未设置CONFIG_URL环境变量"; \
14
- fi
 
 
 
 
15
 
16
- # 可选:设置容器启动时使用的配置路径
17
- ENV CONFIG_PATH=/app/config.json
 
 
 
 
 
 
 
 
 
 
1
  FROM ghcr.io/senshinya/moontv:latest
2
 
3
+ # 切换到root用户以执行安装操作
4
+ USER root
5
 
6
+ # 安装curl用于下载文件
7
+ RUN apk add --no-cache curl
 
8
 
9
+ # 创建启动脚本
10
+ RUN echo $'#!/bin/sh\n\
11
+ set -e\n\
12
+ if [ -n "$CONFIG_URL" ]; then\n\
13
+ echo "Downloading config.json from $CONFIG_URL ..."\n\
14
+ curl -sSLf "$CONFIG_URL" -o /app/config.json\n\
15
+ echo "Download completed, starting application..."\n\
16
+ fi\n\
17
+ exec "$@"' > /app/start.sh
18
 
19
+ # 设置脚本权限
20
+ RUN chmod +x /app/start.sh
21
+
22
+ # 切换回原始非特权用户
23
+ USER nextjs
24
+
25
+ # 使用启动脚本作为入口点
26
+ ENTRYPOINT ["/app/start.sh"]
27
+
28
+ # 保留原始启动命令
29
+ CMD ["node_modules/.bin/next", "start", "-H", "0.0.0.0", "-p", "3000"]