Update Dockerfile
Browse files- Dockerfile +10 -12
Dockerfile
CHANGED
|
@@ -1,33 +1,31 @@
|
|
| 1 |
FROM ghcr.io/su-kaka/gcli2api:latest
|
| 2 |
|
| 3 |
USER root
|
| 4 |
-
# 创建
|
| 5 |
-
RUN mkdir -p /app/creds
|
| 6 |
-
chmod -R 777 /app/creds
|
| 7 |
|
| 8 |
-
# 编写还原逻辑
|
| 9 |
RUN echo 'import os\n\
|
| 10 |
-
def restore(env_name
|
| 11 |
data = os.environ.get(env_name, "").strip()\n\
|
| 12 |
if not data: return\n\
|
| 13 |
-
# 按照 ---END--- 分隔每个文件块\n\
|
| 14 |
blocks = data.split("---END---")\n\
|
| 15 |
for block in blocks:\n\
|
| 16 |
lines = block.strip().split("\\n")\n\
|
| 17 |
if len(lines) < 2: continue\n\
|
| 18 |
filename = lines[0].strip()\n\
|
| 19 |
content = "\\n".join(lines[1:]).strip()\n\
|
| 20 |
-
|
|
|
|
| 21 |
with open(file_path, "w") as f:\n\
|
| 22 |
f.write(content)\n\
|
| 23 |
-
print(f"✅ 已恢复
|
| 24 |
\n\
|
| 25 |
-
|
| 26 |
-
restore("
|
| 27 |
-
restore("ANTIGRAVITY", "/app/creds/antigravity")' > /app/init_creds.py
|
| 28 |
|
| 29 |
ENV PORT=7860
|
| 30 |
-
# 启动
|
| 31 |
ENTRYPOINT ["/bin/sh", "-c", "python3 /app/init_creds.py && exec python web.py"]
|
| 32 |
|
| 33 |
USER 1000
|
|
|
|
| 1 |
FROM ghcr.io/su-kaka/gcli2api:latest
|
| 2 |
|
| 3 |
USER root
|
| 4 |
+
# 修正:直接创建 /app/creds 目录即可
|
| 5 |
+
RUN mkdir -p /app/creds && chmod -R 777 /app/creds
|
|
|
|
| 6 |
|
| 7 |
+
# 编写还原逻辑(去掉 target_dir 参数,全部放进 /app/creds)
|
| 8 |
RUN echo 'import os\n\
|
| 9 |
+
def restore(env_name):\n\
|
| 10 |
data = os.environ.get(env_name, "").strip()\n\
|
| 11 |
if not data: return\n\
|
|
|
|
| 12 |
blocks = data.split("---END---")\n\
|
| 13 |
for block in blocks:\n\
|
| 14 |
lines = block.strip().split("\\n")\n\
|
| 15 |
if len(lines) < 2: continue\n\
|
| 16 |
filename = lines[0].strip()\n\
|
| 17 |
content = "\\n".join(lines[1:]).strip()\n\
|
| 18 |
+
# 修正:直接写入 /app/creds/\n\
|
| 19 |
+
file_path = os.path.join("/app/creds", filename)\n\
|
| 20 |
with open(file_path, "w") as f:\n\
|
| 21 |
f.write(content)\n\
|
| 22 |
+
print(f"✅ 已恢复凭证: {file_path}")\n\
|
| 23 |
\n\
|
| 24 |
+
restore("CREDENTIALS")\n\
|
| 25 |
+
restore("ANTIGRAVITY")' > /app/init_creds.py
|
|
|
|
| 26 |
|
| 27 |
ENV PORT=7860
|
| 28 |
+
# 启动
|
| 29 |
ENTRYPOINT ["/bin/sh", "-c", "python3 /app/init_creds.py && exec python web.py"]
|
| 30 |
|
| 31 |
USER 1000
|