gcli2api / Dockerfile
lengfengy's picture
Update Dockerfile
91a07e8 verified
Raw
History Blame Contribute Delete
1.22 kB
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