created local deployment method that excludes crisp
This commit is contained in:
parent
5e52e096a2
commit
23de0a3bca
7 changed files with 160 additions and 38 deletions
70
deploy.sh
Normal file → Executable file
70
deploy.sh
Normal file → Executable file
|
|
@ -1,11 +1,65 @@
|
|||
# 1. Build
|
||||
docker build -t webui:local -f pond/Dockerfile .
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# 2. Transfer image
|
||||
docker save webui:local | ssh -i ~/.ssh/id_ed25519 carter@172.16.1.20 docker load
|
||||
# Load .env.local if it exists
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ENV_FILE="$SCRIPT_DIR/.env.local"
|
||||
|
||||
# 3. SCP compose file
|
||||
scp -i ~/.ssh/id_ed25519 docker-compose.local.yml carter@172.16.1.20:~/
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
# Export only the vars we care about, ignoring comments and blank lines
|
||||
set -o allexport
|
||||
# shellcheck source=/dev/null
|
||||
source <(grep -E '^(DEPLOY_USER|DEPLOY_HOST|DEPLOY_SSH_KEY)=' "$ENV_FILE")
|
||||
set +o allexport
|
||||
fi
|
||||
|
||||
# 4. Deploy
|
||||
ssh -i ~/.ssh/id_ed25519 carter@172.16.1.20 "docker stack deploy -c docker-compose.local.yml webui"
|
||||
# Prompt for any missing values
|
||||
if [[ -z "${DEPLOY_USER:-}" ]]; then
|
||||
read -rp "SSH username: " DEPLOY_USER
|
||||
fi
|
||||
|
||||
if [[ -z "${DEPLOY_HOST:-}" ]]; then
|
||||
read -rp "Server IP/hostname: " DEPLOY_HOST
|
||||
fi
|
||||
|
||||
if [[ -z "${DEPLOY_SSH_KEY:-}" ]]; then
|
||||
read -rp "SSH key path [~/.ssh/id_ed25519]: " DEPLOY_SSH_KEY
|
||||
DEPLOY_SSH_KEY="${DEPLOY_SSH_KEY:-~/.ssh/id_ed25519}"
|
||||
fi
|
||||
|
||||
SSH_OPTS="-i $DEPLOY_SSH_KEY"
|
||||
|
||||
echo "→ Deploying to $DEPLOY_USER@$DEPLOY_HOST using key $DEPLOY_SSH_KEY"
|
||||
|
||||
# 1. Build frontend (uses indexLocal.html — no Crisp; see vite --mode nocrisp)
|
||||
(
|
||||
cd "$SCRIPT_DIR"
|
||||
npm run build:local
|
||||
)
|
||||
|
||||
# Fail if the bundle still embeds Crisp (wrong vite mode or stale build/)
|
||||
INDEX_HTML="$SCRIPT_DIR/build/index.html"
|
||||
if [[ ! -f "$INDEX_HTML" ]]; then
|
||||
echo "error: missing $INDEX_HTML after build:local" >&2
|
||||
exit 1
|
||||
fi
|
||||
if grep -qiE 'crisp\.chat|\$crisp|CRISP_WEBSITE_ID|CRISP_RUNTIME_CONFIG' "$INDEX_HTML"; then
|
||||
echo "error: build/index.html still references Crisp; expected nocrisp build (indexLocal.html)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Build container image
|
||||
docker build -t webui:local -f Dockerfile .
|
||||
|
||||
# 3. Transfer image
|
||||
docker save webui:local | ssh $SSH_OPTS "$DEPLOY_USER@$DEPLOY_HOST" docker load
|
||||
|
||||
# 4. SCP compose file
|
||||
scp $SSH_OPTS docker-compose.local.yml "$DEPLOY_USER@$DEPLOY_HOST:~/"
|
||||
|
||||
# 5. Deploy — then force service recreate. Swarm often keeps the old task when the tag stays
|
||||
# webui:local after docker load, so without --force you still see the previous HTML/JS.
|
||||
STACK_NAME="${LOCAL_DOCKER_STACK_NAME:-webui}"
|
||||
SERVICE_NAME="${STACK_NAME}_webui"
|
||||
ssh $SSH_OPTS "$DEPLOY_USER@$DEPLOY_HOST" \
|
||||
"docker stack deploy -c docker-compose.local.yml $STACK_NAME && docker service update --force $SERVICE_NAME"
|
||||
Loading…
Add table
Add a link
Reference in a new issue