Skip to content

Commit 51fe872

Browse files
committed
feat: deploy extension sync server with install script
1 parent 0f5a318 commit 51fe872

1 file changed

Lines changed: 118 additions & 1 deletion

File tree

deploy/install-server.sh

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ set -euo pipefail
44
SERVER_IMAGE="${SIMPRINT_SERVER_IMAGE:-ghcr.io/simprint/simprint-server:latest}"
55
UPDATE_IMAGE="${SIMPRINT_UPDATE_IMAGE:-ghcr.io/simprint/simprint-update-server:latest}"
66
CONSOLE_IMAGE="${SIMPRINT_CONSOLE_IMAGE:-ghcr.io/simprint/simprint-console-server:latest}"
7+
EXTENSION_SYNC_IMAGE="${SIMPRINT_EXTENSION_SYNC_IMAGE:-ghcr.io/simprint/simprint-extension-sync-server:latest}"
78

89
TARGET_DIR="$PWD/simprint-self-hosted"
910
CONFIG_DIR="$TARGET_DIR/configs"
1011
COMPOSE_FILE="$TARGET_DIR/docker-compose.yml"
1112
SERVER_CONFIG_FILE="$CONFIG_DIR/server.toml"
1213
UPDATE_CONFIG_FILE="$CONFIG_DIR/update.toml"
1314
CONSOLE_CONFIG_FILE="$CONFIG_DIR/console.toml"
15+
EXTENSION_SYNC_CONFIG_FILE="$CONFIG_DIR/config.prod.yaml"
16+
EXTENSION_SYNC_PRESETS_FILE="$CONFIG_DIR/extensions.yaml"
1417

1518
DEFAULT_APP_SECRET="Nuexz9Y2hRc5Z6HK7Atb"
1619
DEFAULT_POSTGRES_PASSWORD="simprint-postgres-password"
@@ -111,6 +114,28 @@ require_secret_with_default() {
111114
printf -v "$var_name" '%s' "$current_value"
112115
}
113116

117+
create_console_api_key() {
118+
local output=""
119+
local api_key_line=""
120+
121+
output=$(
122+
cd "$TARGET_DIR"
123+
"${COMPOSE_CMD[@]}" run --rm -T --no-deps simprint-console-gateway \
124+
--config /app/configs/console.toml apikey create --name "extension-sync"
125+
)
126+
127+
api_key_line=$(printf '%s\n' "$output" | sed -n 's/^[[:space:]]*X-API-KEY: //p' | tail -n 1)
128+
129+
if [ -z "$api_key_line" ] || [ "${api_key_line#*:}" = "$api_key_line" ]; then
130+
echo "Error: failed to create Console API key for extension sync." >&2
131+
echo "$output" >&2
132+
exit 1
133+
fi
134+
135+
EXTENSION_SYNC_API_KEY_ID="${api_key_line%%:*}"
136+
EXTENSION_SYNC_API_KEY_SECRET="${api_key_line#*:}"
137+
}
138+
114139
if ! check_command docker; then
115140
echo "Error: docker is not installed. Install Docker first." >&2
116141
exit 1
@@ -269,6 +294,47 @@ max_proxies = 99999
269294
max_rpa_tasks = 99999
270295
EOF
271296

297+
cat >"$EXTENSION_SYNC_PRESETS_FILE" <<'EOF'
298+
# Simprint Extension Sync Server preset extensions
299+
300+
preset_extensions: []
301+
302+
categories:
303+
- id: "security"
304+
name: "安全隐私"
305+
name_en: "Security & Privacy"
306+
307+
- id: "development"
308+
name: "开发工具"
309+
name_en: "Developer Tools"
310+
311+
- id: "productivity"
312+
name: "效率工具"
313+
name_en: "Productivity"
314+
315+
- id: "automation"
316+
name: "自动化"
317+
name_en: "Automation"
318+
319+
- id: "other"
320+
name: "其他"
321+
name_en: "Other"
322+
323+
high_risk_permissions:
324+
- "debugger"
325+
- "cookies"
326+
- "webRequest"
327+
- "webRequestBlocking"
328+
- "<all_urls>"
329+
- "nativeMessaging"
330+
- "proxy"
331+
- "history"
332+
- "downloads"
333+
- "management"
334+
- "privacy"
335+
- "browsingData"
336+
EOF
337+
272338
cat >"$COMPOSE_FILE" <<EOF
273339
services:
274340
postgres:
@@ -364,6 +430,20 @@ services:
364430
networks:
365431
- simprint-network
366432
433+
simprint-extension-sync:
434+
image: $EXTENSION_SYNC_IMAGE
435+
container_name: simprint-extension-sync
436+
depends_on:
437+
- simprint-console-gateway
438+
ports:
439+
- "18080:8080"
440+
volumes:
441+
- ./configs:/app/configs:ro
442+
- simprint-extension-sync-data:/app/storage
443+
restart: unless-stopped
444+
networks:
445+
- simprint-network
446+
367447
networks:
368448
simprint-network:
369449
name: simprint-network
@@ -372,21 +452,58 @@ volumes:
372452
simprint-postgres-data:
373453
simprint-redis-data:
374454
simprint-secret-data:
455+
simprint-extension-sync-data:
375456
EOF
376457

377458
echo "Using compose command: ${COMPOSE_CMD[*]}"
378459
echo "Working directory: $TARGET_DIR"
379460
echo "Server image: $SERVER_IMAGE"
380461
echo "Update image: $UPDATE_IMAGE"
381462
echo "Console image: $CONSOLE_IMAGE"
463+
echo "Extension sync image: $EXTENSION_SYNC_IMAGE"
382464
echo "Generated files:"
383465
echo " - $COMPOSE_FILE"
384466
echo " - $SERVER_CONFIG_FILE"
385467
echo " - $UPDATE_CONFIG_FILE"
386468
echo " - $CONSOLE_CONFIG_FILE"
469+
echo " - $EXTENSION_SYNC_CONFIG_FILE"
470+
echo " - $EXTENSION_SYNC_PRESETS_FILE"
471+
472+
(
473+
cd "$TARGET_DIR"
474+
"${COMPOSE_CMD[@]}" up -d postgres redis simprint-server simprint-update-gateway simprint-console-gateway
475+
)
476+
477+
create_console_api_key
478+
479+
cat >"$EXTENSION_SYNC_CONFIG_FILE" <<EOF
480+
# Simprint Extension Sync Server configuration
481+
482+
backend:
483+
api_url: "http://simprint-console-gateway:40043/api/v1"
484+
api_key_id: "$EXTENSION_SYNC_API_KEY_ID"
485+
api_key_secret: "$EXTENSION_SYNC_API_KEY_SECRET"
486+
487+
sync:
488+
full_interval_hours: 24
489+
update_check_interval_minutes: 60
490+
concurrent_downloads: 5
491+
max_retries: 3
492+
493+
logging:
494+
level: "INFO"
495+
format: "console"
496+
497+
http:
498+
host: "0.0.0.0"
499+
port: 8080
500+
501+
storage:
502+
sqlite_path: "storage/extensions.db"
503+
EOF
387504

388505
(
389506
cd "$TARGET_DIR"
390-
"${COMPOSE_CMD[@]}" up -d
507+
"${COMPOSE_CMD[@]}" up -d simprint-extension-sync
391508
"${COMPOSE_CMD[@]}" ps
392509
)

0 commit comments

Comments
 (0)