Files
tasksoftwaretest/deploy/deploy.sh
T
2026-10-29 23:40:41 +01:00

34 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# Builds TaskForge and deploys it to a droplet. Run from Git Bash (or any shell with jai, ssh and scp):
#
# deploy/deploy.sh root@<droplet-ip> tasks.example.com first time (sets up the droplet for that domain)
# deploy/deploy.sh root@<droplet-ip> later updates
#
# The server is cross-compiled to a Linux object file here and linked on the droplet (which has libc etc.).
set -euo pipefail
HOST="${1:?usage: deploy.sh user@host [domain]}"
DOMAIN="${2:-}"
cd "$(dirname "$0")/.."
jai build.jai - web release
jai build.jai - server-linux
ssh "$HOST" 'mkdir -p /opt/taskforge/staging'
scp server/bin/taskforge-server.o web/index.html web/taskforge.js web/taskforge.wasm web/fonts.bin \
deploy/setup-droplet.sh deploy/taskforge.service deploy/Caddyfile \
"$HOST":/opt/taskforge/staging/
ssh "$HOST" "set -e
cd /opt/taskforge/staging
if [ ! -f /etc/systemd/system/taskforge.service ]; then
if [ -z '$DOMAIN' ]; then echo 'First deploy: pass your domain as the second argument.'; exit 1; fi
bash setup-droplet.sh '$DOMAIN'
fi
cc taskforge-server.o -o taskforge-server -no-pie -lm -ldl -lpthread
install -m 755 taskforge-server /opt/taskforge/bin/taskforge-server
install -m 644 index.html taskforge.js taskforge.wasm fonts.bin /opt/taskforge/web/
systemctl restart taskforge
sleep 1
systemctl --no-pager --lines=5 status taskforge"