mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 17:14:03 +00:00
feat(deploy): add VPS compose deployment workflow
Co-authored-by: claw <stanislavkalishin+claw@gmail.com>
This commit is contained in:
27
scripts/ops/vps-bootstrap-ubuntu.sh
Executable file
27
scripts/ops/vps-bootstrap-ubuntu.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
echo "Run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates curl gnupg
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
|
||||
| tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||||
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
systemctl enable docker
|
||||
systemctl start docker
|
||||
|
||||
mkdir -p /opt/household-bot/app /opt/household-bot/env
|
||||
|
||||
echo "Docker installed. Next: place env files in /opt/household-bot/env and deploy the app bundle to /opt/household-bot/app"
|
||||
50
scripts/ops/vps-deploy.sh
Executable file
50
scripts/ops/vps-deploy.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
DEPLOY_ROOT="${DEPLOY_ROOT:-/opt/household-bot}"
|
||||
APP_DIR="${APP_DIR:-$DEPLOY_ROOT/app}"
|
||||
ENV_DIR="${ENV_DIR:-$DEPLOY_ROOT/env}"
|
||||
COMPOSE_FILE="${COMPOSE_FILE:-$APP_DIR/deploy/vps/compose.yml}"
|
||||
|
||||
require_file() {
|
||||
local path="$1"
|
||||
if [[ ! -f "$path" ]]; then
|
||||
echo "Missing required file: $path" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_var() {
|
||||
local name="$1"
|
||||
if [[ -z "${!name:-}" ]]; then
|
||||
echo "Missing required variable: $name" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_var BOT_IMAGE
|
||||
require_var MINIAPP_IMAGE
|
||||
require_file "$COMPOSE_FILE"
|
||||
require_file "$ENV_DIR/bot.env"
|
||||
require_file "$ENV_DIR/miniapp.env"
|
||||
require_file "$ENV_DIR/caddy.env"
|
||||
|
||||
if [[ -n "${GHCR_USERNAME:-}" && -n "${GHCR_TOKEN:-}" ]]; then
|
||||
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin
|
||||
fi
|
||||
|
||||
export BOT_IMAGE
|
||||
export MINIAPP_IMAGE
|
||||
export ENV_DIR
|
||||
export SCHEDULER_POLL_INTERVAL_MS="${SCHEDULER_POLL_INTERVAL_MS:-60000}"
|
||||
export SCHEDULER_DUE_SCAN_LIMIT="${SCHEDULER_DUE_SCAN_LIMIT:-25}"
|
||||
|
||||
mkdir -p "$DEPLOY_ROOT"
|
||||
|
||||
docker compose -f "$COMPOSE_FILE" pull bot miniapp scheduler migrate caddy
|
||||
|
||||
docker compose -f "$COMPOSE_FILE" run --rm --no-deps migrate
|
||||
|
||||
docker compose -f "$COMPOSE_FILE" up -d --remove-orphans bot miniapp scheduler caddy
|
||||
|
||||
docker compose -f "$COMPOSE_FILE" ps
|
||||
Reference in New Issue
Block a user