chore(deploy): systemd unit, push.sh, one-time setup notes

This commit is contained in:
root
2026-05-31 15:32:09 +10:00
parent 692f300af5
commit b5e7478158
3 changed files with 93 additions and 0 deletions

53
deploy/README.md Normal file
View File

@@ -0,0 +1,53 @@
# Deploy notes — Void 2.0
## App deploy (CT 311 — `void2-app`)
One-time setup on the target host:
```bash
# Node 22 (from nodesource if Debian's default is older)
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs
# Service user + working dir
useradd -r -m -d /opt/void-server void
mkdir -p /opt/void-server
chown void: /opt/void-server
# systemd
install -m 644 void-server.service /etc/systemd/system/void-server.service
systemctl daemon-reload
systemctl enable void-server
# Secrets — /opt/void-server/.env must contain:
# DATABASE_URL=postgres://void:<password>@<db-host>:5432/void
# OWNER_TOKEN=<32+ char secret>
# PORT=3000
# NODE_ENV=production
chmod 600 /opt/void-server/.env
chown void: /opt/void-server/.env
```
Then from the dev box:
```bash
cd /project/src/void-v2
./deploy/push.sh
```
## Maintenance
```bash
journalctl -u void-server -f # follow logs
systemctl status void-server # check status
systemctl restart void-server # cycle
# Run migrations on the deployed copy:
ssh root@void2-app 'cd /opt/void-server && npm run migrate'
```
## Notes
- `.env` is excluded from the rsync to avoid clobbering production secrets with dev values.
- The push script uses `--omit=dev` to skip test deps on the target.
- `tests/` is excluded — they're for the dev environment only.

22
deploy/push.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
# Push dev source to void2-app (CT 311) and restart the service.
# Run from /project/src/void-v2.
#
# Override TARGET / REMOTE_DIR via env if needed:
# TARGET=root@192.168.1.16 ./deploy/push.sh
TARGET=${TARGET:-root@void2-app}
REMOTE_DIR=${REMOTE_DIR:-/opt/void-server}
rsync -avz --delete \
--exclude node_modules \
--exclude .git \
--exclude tests \
--exclude coverage \
--exclude .env \
./ "$TARGET:$REMOTE_DIR/"
ssh "$TARGET" "cd $REMOTE_DIR && npm install --omit=dev && systemctl restart void-server"
echo "Deployed."

View File

@@ -0,0 +1,18 @@
[Unit]
Description=Void 2.0 server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=void
WorkingDirectory=/opt/void-server
EnvironmentFile=/opt/void-server/.env
ExecStart=/usr/bin/node /opt/void-server/server.js
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target