Skip to content

Bayanat CLI installer with symlink-based releases#290

Open
level09 wants to merge 5 commits intomainfrom
bayanat-cli
Open

Bayanat CLI installer with symlink-based releases#290
level09 wants to merge 5 commits intomainfrom
bayanat-cli

Conversation

@level09
Copy link
Copy Markdown
Collaborator

@level09 level09 commented Mar 17, 2026

Summary

  • One-command installer (bayanat install [domain]) replaces the manual 20-step installation process
  • Symlink-based release layout (/opt/bayanat/current -> releases/<version>/) for atomic deployments and future update/rollback support
  • SQL migration tracking system with MigrationHistory model and flask apply-migrations CLI command
  • Reliable app reload via uWSGI touch-reload + unix socket (replaces fragile SIGHUP approach)
  • Celery restart via sudoers for config changes from settings dashboard

What's included

CLI installer (bayanat):

  • Installs system deps (PostgreSQL, Redis, Caddy, ffmpeg, uv)
  • Creates bayanat user with minimal sudoers entry
  • Clones latest release tag into /opt/bayanat/releases/<version>/
  • Sets up venv, generates .env, initializes database
  • Configures Caddy (automatic HTTPS), systemd services
  • Symlinks shared resources (.env, media/) across releases
  • Health check after startup

Migration tracking (cherry-pick from automatic-updates):

  • MigrationHistory model tracks applied SQL migrations
  • migration_utils.py runner applies pending .sql files in order
  • flask apply-migrations and flask create-migration commands
  • Existing migrations made idempotent (IF EXISTS guards)

Reload improvements:

  • uWSGI uses unix socket (http-socket) with Caddy as reverse proxy
  • touch-reload=reload.ini for graceful reloads without signal races
  • Dev mode detection: skips reload, asks user to restart manually
  • Celery restart via sudo systemctl restart bayanat-celery

Docs:

  • Quick install section added to deployment/installation.md
  • Manual installation steps preserved unchanged

Directory layout

/opt/bayanat/
  current -> releases/3.1.0/
  releases/
    3.1.0/           # code + .venv
  shared/
    .env             # persists across updates
    media/           # user uploads
    backups/         # DB backups
  system/
  logs/

Test plan

  • Fresh install on Hetzner Ubuntu 24.04 (ARM64) with real domain + SSL
  • Setup wizard completes and reload works
  • bayanat status reports correctly
  • Idempotent re-runs skip completed steps
  • Test on Ubuntu 22.04 (x86_64)
  • Test localhost mode (no domain)

@level09 level09 requested a review from apodacaduron as a code owner March 17, 2026 00:55
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ebde2f7d-ddd4-4928-8d39-e8a01c172104

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bayanat-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@level09 level09 self-assigned this Mar 17, 2026
level09 added 2 commits March 31, 2026 20:02
Symlink-based release system under /opt/bayanat with atomic swaps.
Installs system deps, Caddy, PostgreSQL, uv, generates .env secrets.
Includes uWSGI touch-reload, Celery restart via sudoers, and
dev-mode graceful fallback for config saves.
All 16 SQL files are now in the Alembic baseline revision (6bbb9e68dc26).
Update CONTRIBUTING.md to document flask db migrate workflow.
Preflight checks (OS, arch, disk, network). Atomic Caddy GPG
key write via mktemp. Fixed flask_run quoting with uv run
--directory. Conditional flask db stamp for pre-Alembic releases.
Robust pg_hba.conf with grep -qF guard. Git clone integrity
check as app user. Production .env with FORCE_HTTPS and log paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant