feat: add local test deployment helper
This commit is contained in:
45
scripts/deploy_test_from_mac.sh
Executable file
45
scripts/deploy_test_from_mac.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
DEPLOY_HOST="${DEPLOY_HOST:-root@192.168.2.55}"
|
||||
DEPLOY_PATH="${DEPLOY_PATH:-/opt/workdock}"
|
||||
HEALTH_URL="${HEALTH_URL:-http://192.168.2.55:8088/healthz/}"
|
||||
REMOTE_ENV_FILE="${REMOTE_ENV_FILE:-.env.test}"
|
||||
COMPOSE_FILE="${COMPOSE_FILE:-docker-compose.prod.yml}"
|
||||
RUN_DJANGO_CHECK="${RUN_DJANGO_CHECK:-0}"
|
||||
SSH_CMD="${SSH_CMD:-ssh -4}"
|
||||
RSYNC_SSH="${RSYNC_SSH:-ssh -4}"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
current_branch="$(git branch --show-current)"
|
||||
if [[ "$current_branch" != "develop" ]]; then
|
||||
echo "Expected branch 'develop' for test deployment, got '$current_branch'." >&2
|
||||
echo "Switch to develop or override intentionally before deploying." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating local branch from origin/develop..."
|
||||
git pull --ff-only origin develop
|
||||
|
||||
echo "Syncing repository to ${DEPLOY_HOST}:${DEPLOY_PATH} ..."
|
||||
rsync -az --delete \
|
||||
--exclude '.git' \
|
||||
--exclude '.github' \
|
||||
--exclude '.venv' \
|
||||
--exclude '__pycache__' \
|
||||
--exclude 'node_modules' \
|
||||
--exclude 'backend/media' \
|
||||
--exclude 'backend/staticfiles' \
|
||||
-e "$RSYNC_SSH" \
|
||||
"$REPO_ROOT"/ \
|
||||
"${DEPLOY_HOST}:${DEPLOY_PATH}/"
|
||||
|
||||
echo "Running remote deployment..."
|
||||
$SSH_CMD "$DEPLOY_HOST" \
|
||||
"cd '$DEPLOY_PATH' && RUN_DJANGO_CHECK='$RUN_DJANGO_CHECK' DEPLOY_HEALTH_URL='$HEALTH_URL' ./scripts/deploy_stack.sh '$REMOTE_ENV_FILE' '$COMPOSE_FILE'"
|
||||
|
||||
echo "Verifying health endpoint..."
|
||||
curl --fail --silent --show-error --max-time 10 "$HEALTH_URL" >/dev/null
|
||||
echo "Test deployment healthy: $HEALTH_URL"
|
||||
Reference in New Issue
Block a user