22333Misaka commited on
Commit
ec02a6a
·
verified ·
1 Parent(s): a36dcc8

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -0
Dockerfile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用原版镜像
2
+ FROM ghcr.io/krau/saveany-bot:latest
3
+
4
+ # 切换 root 用户进行安装和权限设置
5
+ USER root
6
+
7
+ # 安装 Python3 (用于运行保活的 Web 服务)
8
+ # 尝试兼容 Alpine 和 Debian 两种系统的安装方式
9
+ RUN (apk add --no-cache python3 || (apt-get update && apt-get install -y python3))
10
+
11
+ # 设置工作目录
12
+ WORKDIR /app
13
+
14
+ # 创建下载缓存目录并赋予 777 权限
15
+ # 虽然你用了 WebDAV,但 bot 还是需要一个临时目录先下载再上传
16
+ RUN mkdir -p /app/downloads && chmod 777 /app/downloads
17
+
18
+ # 创建启动脚本
19
+ # 1. 把环境变量 CONFIG_CONTENT 写入 config.toml
20
+ # 2. 创建假的 index.html
21
+ # 3. 启动 Python Web Server (后台运行)
22
+ # 4. 启动 saveany-bot (前台运行)
23
+ RUN echo '#!/bin/sh' > /app/start.sh && \
24
+ echo 'echo "Generating config file..."' >> /app/start.sh && \
25
+ echo 'echo "$CONFIG_CONTENT" > /app/config.toml' >> /app/start.sh && \
26
+ echo 'echo "Saveany Bot is running..." > /app/index.html' >> /app/start.sh && \
27
+ echo 'echo "Starting Web Server for Keep-Alive..."' >> /app/start.sh && \
28
+ echo 'python3 -m http.server 7860 > /dev/null 2>&1 &' >> /app/start.sh && \
29
+ echo 'echo "Starting Bot..."' >> /app/start.sh && \
30
+ echo './saveany-bot' >> /app/start.sh && \
31
+ chmod +x /app/start.sh
32
+
33
+ # 暴露端口
34
+ EXPOSE 7860
35
+
36
+ # 启动
37
+ CMD ["/app/start.sh"]