Back to vault

CI/CD Pipeline Design for Elixir Releases

Claude api_import · Feb 11, 2026 00:28
user ~24 tokens
Design a CI/CD pipeline for deploying Elixir releases to a VPS. We use GitHub Actions and deploy via SSH.
assistant ~120 tokens
Here's a production-tested pipeline: **Pipeline stages:** Test (compile, credo, format check, tests) -> Build (create release tarball) -> Deploy (upload + activate on VPS) -> Verify (health check). **Key decisions:** Build on CI, not on the VPS. Use rsync --delete to replace the entire release atomically. Health check after deploy. Keep the VPS simple: systemd service + Caddy for TLS.
user ~12 tokens
How do I handle database migrations in this pipeline?
assistant ~140 tokens
Migrations should run as a separate step between upload and restart. **Critical rules:** 1. Migrations must be backwards-compatible. The old code is still running when migrations execute. 2. Two-phase destructive changes: (a) Deploy code that stops using the column. (b) Next deploy: drop the column. 3. Set lock_timeout in migrations that touch hot tables. 4. Keep the previous release tarball for rollback. For Bump: single-instance, the simple approach works. Multi-instance needs rolling deploys with migration locking.
Total: ~296 tokens