mirror of
https://github.com/halfwaystudent/douyin-sparkflow.git
synced 2026-09-06 07:57:09 +08:00
Add Docker Compose one-click deployment
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1 || ! docker compose version >/dev/null 2>&1; then
|
||||
echo "Docker with the Compose plugin is required." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set_env_value() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
local value="$3"
|
||||
if grep -q "^${key}=" "$file"; then
|
||||
local tmp_file
|
||||
tmp_file="$(mktemp)"
|
||||
awk -v key="$key" -v value="$value" '
|
||||
BEGIN { replaced = 0 }
|
||||
$0 ~ "^" key "=" { print key "=" value; replaced = 1; next }
|
||||
{ print }
|
||||
END { if (!replaced) print key "=" value }
|
||||
' "$file" > "$tmp_file"
|
||||
mv "$tmp_file" "$file"
|
||||
else
|
||||
printf '%s=%s\n' "$key" "$value" >> "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ! -f ".env" ]; then
|
||||
cp ".env.example" ".env"
|
||||
fi
|
||||
|
||||
proxy_sub_url="${PROXY_SUB_URL:-${1:-}}"
|
||||
if [ -n "$proxy_sub_url" ]; then
|
||||
set_env_value ".env" "PROXY_SUB_URL" "$proxy_sub_url"
|
||||
fi
|
||||
|
||||
mkdir -p proxy state/cron state/login-profile DouYinSparkFlow/logs
|
||||
if [ ! -f "proxy/config.yaml" ]; then
|
||||
cp "proxy/config.example.yaml" "proxy/config.yaml"
|
||||
fi
|
||||
|
||||
bash ./refresh_proxy.sh
|
||||
docker compose up -d --build
|
||||
|
||||
web_port="$(grep '^WEB_PORT=' .env | sed 's/^WEB_PORT=//')"
|
||||
web_port="${web_port:-8787}"
|
||||
url="http://localhost:${web_port}"
|
||||
echo "Douyin SparkFlow is running: $url"
|
||||
echo "Next: create the admin password, open the login desktop, scan the QR code, select target friends, and set the send window."
|
||||
|
||||
if command -v xdg-open >/dev/null 2>&1; then
|
||||
xdg-open "$url" >/dev/null 2>&1 || true
|
||||
elif command -v open >/dev/null 2>&1; then
|
||||
open "$url" >/dev/null 2>&1 || true
|
||||
fi
|
||||
Reference in New Issue
Block a user