Repository navigation
Add a repeatable origin/main production deploy - #1
Open
leminh0796 wants to merge 1 commit into
Open
leminh0796 wants to merge 1 commit into
leminh0796 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bin/deploydeploys the exact commit currently onorigin/main. It leaves the current branch and working tree alone.The command loads
.kamal/production.envitself (mode0600, gitignored)..kamal/secretsstill mapsSECRET_KEY_BASEfromRAILS_MASTER_KEY. Required values are checked before any container is stopped. A missing file can be filled from the running container withbin/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: falseand127.0.0.1:3006published, that fails with "port is already allocated".bin/deploybuilds and pulls while the current container is still serving, backs up the SQLite databases onfizzy_storage, then stops the old container insidekamal 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:prepareon 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.
SECRET_KEY_BASEontoRAILS_MASTER_KEYand the SMTP names ontoAWS_SES_SMTP_*, writes mode0600, and refuses to replace an existing file.bin/deployis blocked by.kamal/deploy.lock.bin/deploy --preflightwith stand-in secrets resolvedorigin/maind666b2b6f597bbd80c6aa9d5ada720fc7a10f69aand stopped atbin/kamal versionon this machine (trilogyis not installed here). It did not open SSH.https://fizzy.minhcode.net/upreturned HTTP 200 with a valid certificate, and/followed tohttps://fizzy.minhcode.net/session/newwith HTTP 200.Next command
On the machine that has Docker, Ruby, and SSH to the host:
bin/deployis the deploy. Run it only when a short outage is acceptable.