blitz-js / blitz-js/legacy-framework
Support zero-downtime build folder swapping
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### What do you want and why?
I'd like to change `blitz build` to use a temporary folder for the new build and once the build is done move all files to the final folder that is used by the production server.
Why?
When deploying a new version and the process looks like the following, then the running instance will break because the current build is removed once `blitz build` is executed, as that command will remove the current build used by the production server.
1. Push changes to git from your development machine or CI
2. Pull these changes on your server
3. Run `blitz build` to re-build using the new changes
4. Re-start service, e.g. using pm2.
### Possible implementation(s)
In https://github.com/blitz-js/blitz/blob/canary/packages/server/src/build.ts, either use something like `${buildFolder}_TMP` and then add a last step to move from `${buildFolder}_TMP` to `buildFolder`, or actually support choosing a temporary build folder via the config (aka tmpBuildFolder).
### Additional context
Maybe I'm missing something here, but neither `blitz build` nor `blitz start` have additional parameters to make a no-downtime deployment of a new version in production possible.
I know there are other ways, like building during CI/CD and then pushing all artifacts to the server. If my suggestion won't be supported than this is the way I'll go. I just stumbled upon this issue in a side project before I had CI/CD setup.
Contributor guide
Assessment
This issue has not been assessed yet.