forked from defunkt/toes
Add remote:deploy script for release deployment
This commit is contained in:
parent
e5e82f3085
commit
a8c4975ed5
|
|
@ -26,6 +26,7 @@
|
||||||
"debug": "DEBUG=1 bun run dev",
|
"debug": "DEBUG=1 bun run dev",
|
||||||
"dev": "bun run templates && rm -f pub/client/index.js && bun run --hot src/server/index.tsx",
|
"dev": "bun run templates && rm -f pub/client/index.js && bun run --hot src/server/index.tsx",
|
||||||
"remote:migrate": "bun run scripts/migrate.ts",
|
"remote:migrate": "bun run scripts/migrate.ts",
|
||||||
|
"remote:deploy": "./scripts/remote-deploy.sh",
|
||||||
"remote:install": "./scripts/remote-install.sh",
|
"remote:install": "./scripts/remote-install.sh",
|
||||||
"remote:logs": "./scripts/remote-logs.sh",
|
"remote:logs": "./scripts/remote-logs.sh",
|
||||||
"remote:restart": "./scripts/remote-restart.sh",
|
"remote:restart": "./scripts/remote-restart.sh",
|
||||||
|
|
|
||||||
62
scripts/remote-deploy.sh
Executable file
62
scripts/remote-deploy.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Build a release tarball, upload it to the Pi, and install it.
|
||||||
|
# Usage: bun run remote:deploy
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
ROOT_DIR="$SCRIPT_DIR/.."
|
||||||
|
|
||||||
|
source "$ROOT_DIR/scripts/config.sh"
|
||||||
|
|
||||||
|
# Build release tarball
|
||||||
|
"$ROOT_DIR/scripts/release.sh"
|
||||||
|
|
||||||
|
# Find the tarball
|
||||||
|
TARBALL=$(ls -1 "$ROOT_DIR"/dist/toes-*.tar.gz 2>/dev/null | head -1)
|
||||||
|
[ -f "$TARBALL" ] || { echo "ERROR: No tarball found in dist/"; exit 1; }
|
||||||
|
FILENAME=$(basename "$TARBALL")
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ">> Uploading $FILENAME to $SSH_HOST"
|
||||||
|
scp "$TARBALL" "$SSH_HOST:/tmp/$FILENAME"
|
||||||
|
|
||||||
|
echo ">> Installing on $SSH_HOST"
|
||||||
|
ssh "$SSH_HOST" bash <<SCRIPT
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DEST=~/toes
|
||||||
|
APPS_DIR=~/apps
|
||||||
|
DATA_DIR=~/data
|
||||||
|
|
||||||
|
mkdir -p "\$DEST"
|
||||||
|
tar xzf "/tmp/$FILENAME" --strip-components=1 -C "\$DEST"
|
||||||
|
rm "/tmp/$FILENAME"
|
||||||
|
|
||||||
|
cd "\$DEST"
|
||||||
|
~/.bun/bin/bun install > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Bundled apps (parallel)
|
||||||
|
REPOS_DIR="\$DATA_DIR/repos"
|
||||||
|
mkdir -p "\$REPOS_DIR" "\$APPS_DIR"
|
||||||
|
|
||||||
|
pids=()
|
||||||
|
for app_dir in "\$DEST"/apps/*/; do
|
||||||
|
app=\$(basename "\$app_dir")
|
||||||
|
[ -f "\$app_dir/package.json" ] || continue
|
||||||
|
(
|
||||||
|
cp -a "\$app_dir" "\$APPS_DIR/\$app"
|
||||||
|
~/.bun/bin/bun install --frozen-lockfile --cwd "\$APPS_DIR/\$app" > /dev/null 2>&1 \
|
||||||
|
|| ~/.bun/bin/bun install --cwd "\$APPS_DIR/\$app" > /dev/null 2>&1
|
||||||
|
) &
|
||||||
|
pids+=("\$!")
|
||||||
|
done
|
||||||
|
for pid in "\${pids[@]}"; do wait "\$pid"; done
|
||||||
|
|
||||||
|
# Pre-built repos and CLI
|
||||||
|
cp -a "\$DEST"/dist/repos/*.git "\$REPOS_DIR/" 2>/dev/null || true
|
||||||
|
sudo install -m 755 "\$DEST/dist/toes" /usr/local/bin/toes
|
||||||
|
|
||||||
|
sudo systemctl restart toes
|
||||||
|
echo ">> Done"
|
||||||
|
SCRIPT
|
||||||
Loading…
Reference in New Issue
Block a user