File size: 1,220 Bytes
a0a83ef
 
8612b78
91a07e8
 
 
8612b78
91a07e8
56905fc
91a07e8
56905fc
 
 
 
 
 
91a07e8
 
 
 
 
 
 
 
56905fc
d25a7b6
 
a0a83ef
56905fc
91a07e8
56905fc
8612b78
56905fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
FROM ghcr.io/su-kaka/gcli2api:latest

USER root
# 创建目录,注意这次我们直接在根目录下尝试
RUN mkdir -p /app/credentials /app/antigravity /app/creds && \
    chmod -R 777 /app

# 修改 Python 脚本,同时往两个可能的地方写文件
RUN echo 'import os\n\
def restore(env_name, folder_name):\n\
    data = os.environ.get(env_name, "").strip()\n\
    if not data: return\n\
    blocks = data.split("---END---")\n\
    for block in blocks:\n\
        lines = block.strip().split("\\n")\n\
        if len(lines) < 2: continue\n\
        fname = lines[0].strip()\n\
        content = "\\n".join(lines[1:])\n\
        # 方案:同时写入程序可能读取的两个位置\n\
        paths = [f"/app/{folder_name}/{fname}", f"/app/creds/{folder_name}/{fname}"]\n\
        for p in paths:\n\
            os.makedirs(os.path.dirname(p), exist_ok=True)\n\
            with open(p, "w") as f: f.write(content)\n\
            print(f"✅ 已恢复到: {p}")\n\
\n\
restore("CREDENTIALS", "credentials")\n\
restore("ANTIGRAVITY", "antigravity")' > /app/init_creds.py

ENV PORT=7860
# 强制程序重新扫描
ENTRYPOINT ["/bin/sh", "-c", "python3 /app/init_creds.py && exec python web.py"]

USER 1000