Spaces:
Running
Running
Create docker-entrypoint.sh
Browse files- docker-entrypoint.sh +52 -0
docker-entrypoint.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
echo "[Grok2API] 正在初始化环境..."
|
| 5 |
+
|
| 6 |
+
# 确保数据目录存在(在 /app/data 下)
|
| 7 |
+
mkdir -p /app/data/temp/image /app/data/temp/video /app/logs
|
| 8 |
+
|
| 9 |
+
# 如果 setting.toml 不存在,创建默认配置
|
| 10 |
+
# 注意:如果连接远程 PgSQL,通常通过环境变量注入,这里的 setting.toml 是基础配置
|
| 11 |
+
if [ ! -f /app/data/setting.toml ]; then
|
| 12 |
+
echo "[Grok2API] 初始化 setting.toml..."
|
| 13 |
+
cat > /app/data/setting.toml << 'EOF'
|
| 14 |
+
[global]
|
| 15 |
+
base_url = "http://localhost:7860"
|
| 16 |
+
log_level = "INFO"
|
| 17 |
+
image_mode = "url"
|
| 18 |
+
admin_password = "admin"
|
| 19 |
+
admin_username = "admin"
|
| 20 |
+
image_cache_max_size_mb = 512
|
| 21 |
+
video_cache_max_size_mb = 1024
|
| 22 |
+
max_upload_concurrency = 20
|
| 23 |
+
max_request_concurrency = 50
|
| 24 |
+
batch_save_interval = 1.0
|
| 25 |
+
batch_save_threshold = 10
|
| 26 |
+
|
| 27 |
+
[grok]
|
| 28 |
+
api_key = ""
|
| 29 |
+
proxy_url = ""
|
| 30 |
+
cache_proxy_url = ""
|
| 31 |
+
cf_clearance = ""
|
| 32 |
+
x_statsig_id = ""
|
| 33 |
+
dynamic_statsig = true
|
| 34 |
+
filtered_tags = "xaiartifact,xai:tool_usage_card,grok:render"
|
| 35 |
+
stream_chunk_timeout = 120
|
| 36 |
+
stream_total_timeout = 600
|
| 37 |
+
stream_first_response_timeout = 30
|
| 38 |
+
temporary = true
|
| 39 |
+
show_thinking = true
|
| 40 |
+
proxy_pool_url = ""
|
| 41 |
+
proxy_pool_interval = 300
|
| 42 |
+
retry_status_codes = [401, 429]
|
| 43 |
+
EOF
|
| 44 |
+
fi
|
| 45 |
+
|
| 46 |
+
if [ ! -f /app/data/token.json ]; then
|
| 47 |
+
echo "[Grok2API] 初始化 token.json..."
|
| 48 |
+
echo '{"ssoNormal": {}, "ssoSuper": {}}' > /app/data/token.json
|
| 49 |
+
fi
|
| 50 |
+
|
| 51 |
+
echo "[Grok2API] 启动应用..."
|
| 52 |
+
exec "$@"
|