lengfengy commited on
Commit
e3d18f3
·
verified ·
1 Parent(s): 56905fc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. 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/credentials /app/creds/antigravity && \
6
- chmod -R 777 /app/creds
7
 
8
- # 编写还原逻辑的 Python 脚本
9
  RUN echo 'import os\n\
10
- def restore(env_name, target_dir):\n\
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
- file_path = os.path.join(target_dir, filename)\n\
 
21
  with open(file_path, "w") as f:\n\
22
  f.write(content)\n\
23
- print(f"✅ 已恢复文件: {file_path}")\n\
24
  \n\
25
- # 执行还原\n\
26
- restore("CREDENTIALS", "/app/creds/credentials")\n\
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