2.4 KiB
CarPass Deploy
First Install
sudo mkdir -p /opt/carpass
sudo chown "$USER":"$USER" /opt/carpass
git clone <repo-url> /opt/carpass/app
cd /opt/carpass/app
cp .env.example .env
Edit .env and set real secrets:
BOT_TOKENBOT_USERNAMEPUBLIC_WEBAPP_URLCORS_ORIGINSINTERNAL_API_TOKENSECRET_KEYREDIS_URLif Redis is externalVAPID_PUBLIC_KEY/VAPID_PRIVATE_KEYwhen browser push is enabledADMIN_TELEGRAM_IDS
Production must use public HTTPS URLs and ALLOW_DEV_AUTH=false.
Start
docker compose up -d --build
docker compose exec api alembic upgrade head
python -m scripts.bootstrap_admin
curl -fsS http://127.0.0.1:8000/ready
The default compose stack includes Postgres, Redis, API and bot services with health checks, restart policies and log rotation.
Git-Based Update
The server directory must remain a git clone. The main update path is:
APP_DIR=/opt/carpass/app DEPLOY_BRANCH=main ./scripts/deploy.sh
The script runs:
git fetchgit pull --ff-only- optional DB backup with
BACKUP_BEFORE_DEPLOY=true - Docker build/up
alembic upgrade head- Python smoke compile
/readyhealth check
Do not use rsync as the primary deploy mechanism.
Rollback
cd /opt/carpass/app
git log --oneline -20
git checkout <previous_commit>
docker compose up -d --build
curl -fsS http://127.0.0.1:8000/ready
Be careful with database migrations: code rollback does not automatically downgrade data.
Backups
Create a compressed custom-format dump before risky deploys:
BACKUP_DIR=/opt/carpass/backups ./scripts/backup_db.sh
Restore only during a maintenance window:
./scripts/restore_db.sh /opt/carpass/backups/carpass-drivers-YYYYMMDDTHHMMSSZ.dump
For volume-level recovery, back up the Docker named volumes pgdata and redisdata according to the host backup policy.
Logs
docker compose ps
docker compose logs -f api
docker compose logs -f bot
docker compose logs -f db
Migration Smoke Check
For a configured Postgres database:
./scripts/check_migrations.sh
Cleanup Jobs
Run periodic cleanup from cron or systemd timer:
docker compose exec -T api python scripts/cleanup_jobs.py
It expires stale employee invites, marks exhausted notifications as abandoned, removes old abandoned notifications and clears old draft work orders.