profileShare

rasmusjy / voicetask

Read-only snapshot

No repository description.

main default branch 105 files Expires Sep 13, 2026, 9:06 AM
deploy.sh 1,839 bytes
1 #!/usr/bin/env bash
2 # One-command redeploy for voicetask.rasmusj.com.
3 #
4 # Ships the source to the VPS, builds the image there and restarts the
5 # container. Run from Git Bash on Windows: ./deploy.sh
6 #
7 # The shared reverse proxy at /opt/caddy is never touched, so a routine redeploy
8 # cannot take the other sites on the box down with it.
9 #
10 # There is no .env: the public instance runs on the offline mock providers and
11 # has no keys to lose.
12 set -euo pipefail
13
14 # Deploy target. Kept out of the repository on purpose: this code is shared
15 # read-only with people outside the project, and the server address and
16 # login are not theirs to have. Set it once in your shell:
17 #
18 # export VPS=user@host
19 #
20 VPS=${VPS:?set VPS=user@host before deploying}
21 DEST=/opt/projects/voicetask
22
23 cd "$(dirname "$0")"
24
25 echo "==> Running the test suite before shipping anything..."
26 npm test
27
28 echo "==> Ensuring VPS project dir exists..."
29 ssh "$VPS" "mkdir -p '$DEST'"
30
31 echo "==> Uploading source (node_modules, dist, data and .env stay out of it)..."
32 tar --exclude=node_modules --exclude=dist --exclude=data --exclude=.env \
33 --exclude=.git --exclude=coverage -czf - . | ssh "$VPS" "
34 rm -rf '$DEST/src.tmp' &&
35 mkdir -p '$DEST/src.tmp' &&
36 tar -C '$DEST/src.tmp' -xzf - &&
37 rm -rf '$DEST/app' &&
38 mv '$DEST/src.tmp' '$DEST/app'
39 "
40
41 echo "==> Building and restarting the container..."
42 ssh "$VPS" "cd '$DEST/app' && docker compose up -d --build"
43
44 echo "==> Waiting for the health check to go green..."
45 ssh "$VPS" "
46 for i in \$(seq 1 20); do
47 state=\$(docker inspect -f '{{.State.Health.Status}}' voicetask 2>/dev/null || echo starting)
48 [ \"\$state\" = healthy ] && echo ' healthy' && exit 0
49 sleep 3
50 done
51 echo ' still not healthy, check: docker logs voicetask'
52 exit 1
53 "
54
55 echo ""
56 echo "==> Done. Live at https://voicetask.rasmusj.com"
57