Update Dockerfile
Browse files- Dockerfile +11 -9
Dockerfile
CHANGED
|
@@ -1,28 +1,30 @@
|
|
| 1 |
FROM ghcr.io/su-kaka/gcli2api:latest
|
| 2 |
|
| 3 |
USER root
|
| 4 |
-
#
|
| 5 |
-
RUN mkdir -p /app/creds
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 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 |
-
|
| 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"✅ 已恢复
|
| 23 |
\n\
|
| 24 |
-
|
| 25 |
-
restore("
|
|
|
|
| 26 |
|
| 27 |
ENV PORT=7860
|
| 28 |
# 启动
|
|
|
|
| 1 |
FROM ghcr.io/su-kaka/gcli2api:latest
|
| 2 |
|
| 3 |
USER root
|
| 4 |
+
# 1. 创建精确的子目录层级
|
| 5 |
+
RUN mkdir -p /app/creds/credentials /app/creds/antigravity && \
|
| 6 |
+
chmod -R 777 /app/creds
|
| 7 |
|
| 8 |
+
# 2. 修改 Python 脚本,根据 Secret 存入对应的子文件夹
|
| 9 |
RUN echo 'import os\n\
|
| 10 |
+
def restore(env_name, sub_folder):\n\
|
| 11 |
data = os.environ.get(env_name, "").strip()\n\
|
| 12 |
if not data: return\n\
|
| 13 |
+
target_path = f"/app/creds/{sub_folder}"\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 |
+
file_path = os.path.join(target_path, filename)\n\
|
|
|
|
| 21 |
with open(file_path, "w") as f:\n\
|
| 22 |
f.write(content)\n\
|
| 23 |
+
print(f"✅ 已恢复到 {sub_folder}: {filename}")\n\
|
| 24 |
\n\
|
| 25 |
+
# 凭证归位\n\
|
| 26 |
+
restore("CREDENTIALS", "credentials")\n\
|
| 27 |
+
restore("ANTIGRAVITY", "antigravity")' > /app/init_creds.py
|
| 28 |
|
| 29 |
ENV PORT=7860
|
| 30 |
# 启动
|