8000 Add a repeatable origin/main production deploy by leminh0796 · Pull Request #1 · leminh0796/fizzy · GitHub
[go: up one dir, main page]

Skip to content

Add a repeatable origin/main production deploy - #1

Open
leminh0796 wants to merge 1 commit into
mainfrom
cursor/production-deploy-command-82d3
Open

leminh0796 wants to merge 1 commit into
mainfrom
cursor/production-deploy-command-82d3

Conversation

@leminh0796
Copy link
Copy Markdown
Owner

Summary

bin/deploy deploys the exact commit currently on origin/main. It leaves the current branch and working tree alone.

The command loads .kamal/production.env itself (mode 0600, gitignored). .kamal/secrets still maps SECRET_KEY_BASE from RAILS_MASTER_KEY. Required values are checked before any container is stopped. A missing file can be filled from the running container with bin/deploy --import-secrets; values are not printed and an existing file is not overwritten.

Kamal 2.12 starts the new container before it stops the old one. With proxy: false and 127.0.0.1:3006 published, that fails with "port is already allocated". bin/deploy builds and pulls while the current container is still serving, backs up the SQLite databases on fizzy_storage, then stops the old container inside kamal app boot's deploy lock and starts the new SHA. Expect brief downtime. Nginx, the published port, and the volume stay as they are.

If boot or the startup checks fail after that stop, the SQLite backup is restored before the previous release is booted. The entrypoint runs db:prepare on boot, so the previous release is not started against a newer schema.

Details, prerequisites, and manual recovery are in docs/production-deploy.md.

Verification

No production deploy was run, and no production container was stopped.

  • Missing, empty, and group-readable secrets fail by variable name and do not print values.
  • A mock import maps the running container's SECRET_KEY_BASE onto RAILS_MASTER_KEY and the SMTP names onto AWS_SES_SMTP_*, writes mode 0600, and refuses to replace an existing file.
  • The boot hook records cutover only after the stop command succeeds.
  • A second bin/deploy is blocked by .kamal/deploy.lock.
  • bin/deploy --preflight with stand-in secrets resolved origin/main d666b2b6f597bbd80c6aa9d5ada720fc7a10f69a and stopped at bin/kamal version on this machine (trilogy is not installed here). It did not open SSH.
  • Read-only checks against the current site: https://fizzy.minhcode.net/up returned HTTP 200 with a valid certificate, and / followed to https://fizzy.minhcode.net/session/new with HTTP 200.

Next command

On the machine that has Docker, Ruby, and SSH to the host:

bin/deploy --import-secrets
bin/deploy --preflight
bin/deploy

bin/deploy is the deploy. Run it only when a short outage is acceptable.

Open in Web Open in Cursor 

bin/deploy loads a gitignored secrets file, builds the fetched origin/main
commit while the current container keeps serving, and stops that container
only inside Kamal's boot lock so port 3006 can move. A failed boot restores
the SQLite backup before the previous release starts. Downtime is expected.

Co-authored-by: Duke (real) <tlminh@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0