Skip to content

Latest commit

 

History

History
80 lines (61 loc) · 3.04 KB

File metadata and controls

80 lines (61 loc) · 3.04 KB

MSK Paste — Deployment

This folder contains everything needed to deploy MSK Paste on a Debian / Ubuntu server with Apache2 as the reverse proxy.

File Purpose
scripts/install.sh One-shot server setup (run once)
scripts/update.sh Manual update fallback (info only)
scripts/backup.sh gzip MariaDB dump with 14-day retention
apache/msk-paste.conf Reference vhost (generated by install.sh)
../msk-paste.service systemd unit (deployed via SCP)

🆕 First-time server setup

curl -fsSL https://raw.githubusercontent.com/MSK-Scripts/msk-paste/main/deployment/scripts/install.sh \
  | sudo bash

The script will ask for:

  • the domain (default paste.msk-scripts.de)
  • your Let's Encrypt email
  • whether to request the certificate now

…and produces:

  • a musiker15-owned /opt/msk-paste/ directory
  • a chmod-600 /opt/msk-paste/.env with random DB_PASSWORD and IP_HASH_SECRET
  • an Apache vhost at /etc/apache2/sites-available/msk-paste.conf
  • an SSL certificate (if you confirmed Certbot)

🚀 Code deploy

Pushes to main trigger .github/workflows/deploy.yml:

  1. Build the Next.js app in CI
  2. SCP .next/, public/, src/, migrations/, messages/, scripts/, package.json, package-lock.json, next.config.ts, tsconfig.json, msk-paste.service to /opt/msk-paste/
  3. systemctl stop msk-paste
  4. npm ci --omit=dev && npm install --no-save tsx
  5. npm run migrate
  6. systemctl daemon-reload && systemctl restart msk-paste

Required GitHub Secrets:

Secret Value
FTP_SERVER server IP or hostname
FTP_USERNAME root
FTP_PORT 22 (or your custom SSH port)
SSH_PRIVATE_KEY private key matching ~/.ssh/authorized_keys
NEXT_PUBLIC_BASE_URL https://paste.msk-scripts.de

🔧 Daily operations

# Service status
systemctl status msk-paste
journalctl -u msk-paste -f

# Database backup (kept for 14 days)
sudo bash /opt/msk-paste/deployment/scripts/backup.sh

# Cron: backup + cleanup
0 3 * * * /opt/msk-paste/deployment/scripts/backup.sh
30 3 * * * cd /opt/msk-paste && /usr/bin/npx tsx scripts/cleanup.ts >> /var/log/msk-paste-cleanup.log 2>&1

🩹 Troubleshooting

  • App returns 502 → check journalctl -u msk-paste -e. Most often this is DB_HOST/credentials in /opt/msk-paste/.env.
  • CSS missing → ensure chown -R musiker15:musiker15 /opt/msk-paste/ and that .next/ is writable.
  • Migration failed in deploy → run npm run migrate on the server manually as the deploy user (or as root with the right env loaded).