Simford.Dong commited on
Commit ·
d0a6395
1
Parent(s): 0a53576
Fix: switch to env var auth in openclaw.json and remove auth-profiles.json
Browse files- Dockerfile +7 -25
Dockerfile
CHANGED
|
@@ -23,7 +23,8 @@ set -x\n\
|
|
| 23 |
\n\
|
| 24 |
# Check for required environment variables\n\
|
| 25 |
if [ -z "$GEMINI_API_KEY_1" ]; then\n\
|
| 26 |
-
echo "
|
|
|
|
| 27 |
fi\n\
|
| 28 |
\n\
|
| 29 |
# Create critical missing directories\n\
|
|
@@ -31,36 +32,17 @@ 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 |
-
#
|
| 35 |
-
|
| 36 |
-
echo "Generating auth-profiles.json..."\n\
|
| 37 |
-
\n\
|
| 38 |
-
# Construct the JSON content with correct structure\n\
|
| 39 |
-
JSON_CONTENT="{\n\
|
| 40 |
-
\"auth\": {\n\
|
| 41 |
-
\"profiles\": {\n\
|
| 42 |
-
\"google-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 |
-
\n\
|
| 56 |
-
echo -e "$JSON_CONTENT" > /root/.openclaw/agents/main/agent/auth-profiles.json\n\
|
| 57 |
\n\
|
| 58 |
# Generate minimal config if not exists\n\
|
| 59 |
if [ ! -f /root/.openclaw/openclaw.json ]; then\n\
|
| 60 |
cat > /root/.openclaw/openclaw.json << EOF\n\
|
| 61 |
{\n\
|
| 62 |
"env": {\n\
|
| 63 |
-
"GOOGLE_API_KEY": "${GEMINI_API_KEY_1}"\n\
|
|
|
|
|
|
|
| 64 |
},\n\
|
| 65 |
"gateway": {\n\
|
| 66 |
"mode": "local",\n\
|
|
|
|
| 23 |
\n\
|
| 24 |
# Check for required environment variables\n\
|
| 25 |
if [ -z "$GEMINI_API_KEY_1" ]; then\n\
|
| 26 |
+
echo "ERROR: GEMINI_API_KEY_1 is not set. Agent will fail. Exiting."\n\
|
| 27 |
+
exit 1\n\
|
| 28 |
fi\n\
|
| 29 |
\n\
|
| 30 |
# Create critical missing directories\n\
|
|
|
|
| 32 |
mkdir -p /root/.openclaw/agents/main/sessions\n\
|
| 33 |
mkdir -p /root/.openclaw/credentials\n\
|
| 34 |
\n\
|
| 35 |
+
# Remove auth-profiles.json if it exists to force env var usage\n\
|
| 36 |
+
rm -f /root/.openclaw/agents/main/agent/auth-profiles.json\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
\n\
|
| 38 |
# Generate minimal config if not exists\n\
|
| 39 |
if [ ! -f /root/.openclaw/openclaw.json ]; then\n\
|
| 40 |
cat > /root/.openclaw/openclaw.json << EOF\n\
|
| 41 |
{\n\
|
| 42 |
"env": {\n\
|
| 43 |
+
"GOOGLE_API_KEY": "${GEMINI_API_KEY_1}",\n\
|
| 44 |
+
"GEMINI_API_KEY": "${GEMINI_API_KEY_1}",\n\
|
| 45 |
+
"GOOGLE_GENERATIVE_AI_API_KEY": "${GEMINI_API_KEY_1}"\n\
|
| 46 |
},\n\
|
| 47 |
"gateway": {\n\
|
| 48 |
"mode": "local",\n\
|