Simford.Dong commited on
Commit
8d24432
·
1 Parent(s): c37c186

Fix: robust auth-profiles.json generation for Gemini

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -11
Dockerfile CHANGED
@@ -21,25 +21,38 @@ EXPOSE 7860
21
  RUN echo '#!/bin/bash\n\
22
  set -x\n\
23
  \n\
 
 
 
 
 
24
  # Create critical missing directories\n\
25
  mkdir -p /root/.openclaw/agents/main/agent\n\
26
  mkdir -p /root/.openclaw/agents/main/sessions\n\
27
  mkdir -p /root/.openclaw/credentials\n\
28
  \n\
29
- # Generate auth-profiles.json for the main agent if it doesn'\''t exist\n\
 
30
  if [ ! -f /root/.openclaw/agents/main/agent/auth-profiles.json ]; then\n\
31
- cat > /root/.openclaw/agents/main/agent/auth-profiles.json << EOF\n\
32
- {\n\
33
- "profiles": {\n\
34
- "gemini-default": {\n\
35
- "provider": "google",\n\
36
- "apiKey": "${GEMINI_API_KEY_1}",\n\
37
- "baseUrl": "${OPENCLAW_GEMINI_BASE_URL}",\n\
38
- "type": "api_key"\n\
 
 
 
 
 
 
39
  }\n\
40
  }\n\
41
- }\n\
42
- EOF\n\
 
43
  fi\n\
44
  \n\
45
  # Generate minimal config if not exists\n\
 
21
  RUN echo '#!/bin/bash\n\
22
  set -x\n\
23
  \n\
24
+ # Check for required environment variables\n\
25
+ if [ -z "$GEMINI_API_KEY_1" ]; then\n\
26
+ echo "WARNING: GEMINI_API_KEY_1 is not set. Agent may fail to authenticate."\n\
27
+ fi\n\
28
+ \n\
29
  # Create critical missing directories\n\
30
  mkdir -p /root/.openclaw/agents/main/agent\n\
31
  mkdir -p /root/.openclaw/agents/main/sessions\n\
32
  mkdir -p /root/.openclaw/credentials\n\
33
  \n\
34
+ # Generate auth-profiles.json for the main agent\n\
35
+ # We handle optional baseUrl dynamically\n\
36
  if [ ! -f /root/.openclaw/agents/main/agent/auth-profiles.json ]; then\n\
37
+ echo "Generating auth-profiles.json..."\n\
38
+ \n\
39
+ # Construct the JSON content\n\
40
+ JSON_CONTENT="{\n\
41
+ \"profiles\": {\n\
42
+ \"gemini-default\": {\n\
43
+ \"provider\": \"google\",\n\
44
+ \"apiKey\": \"${GEMINI_API_KEY_1}\",\n"\n\
45
+ \n\
46
+ if [ -n "$OPENCLAW_GEMINI_BASE_URL" ]; then\n\
47
+ JSON_CONTENT="${JSON_CONTENT} \"baseUrl\": \"${OPENCLAW_GEMINI_BASE_URL}\",\n"\n\
48
+ fi\n\
49
+ \n\
50
+ JSON_CONTENT="${JSON_CONTENT} \"type\": \"api_key\"\n\
51
  }\n\
52
  }\n\
53
+ }"\n\
54
+ \n\
55
+ echo -e "$JSON_CONTENT" > /root/.openclaw/agents/main/agent/auth-profiles.json\n\
56
  fi\n\
57
  \n\
58
  # Generate minimal config if not exists\n\