Zero-downtime deployment
This type of deployment is applied for applications that require constant uptime. Buddy achieves that by:
A. Uploading the files to a separate directory on the server
B. Switching the symbolic link to the current version once the deployment has finished
Configuration
- Create a new project and connect it to the repository from which you want to deploy (GitHub, Bitbucket, etc.).
- Add a new pipeline and set up the trigger mode and deployment branch:
Image loading...
- With the pipeline added, you can configure the deployment. Switch to the Transfer section and click Atomic Deployment:
Image loading...
- The last step is configuring the access details to your server, similar to setting up an SFTP deployment.
current/
, deploy-cache/
and releases/
inside this path. Make sure that your server serves the application from the $REMOTE_PATH/current
folder.
How zero-downtime deployments work
A. Buddy creates 3 folders on your server in the provided path:
current/
– a symbolic link to the current version in thereleases
directory to which your web server pointsreleases/
– contains the history of uploaded releases. For each version a directory with the name of the revision tag is createddeploy-cache/
– used for storing new files during the deployment. Once the upload has finished, its contents are copied to a new directory in the/releases
directory.
B. The template adds two actions to your pipeline:
- An SFTP action which uploads the changes to the
deploy-cache/
folder. The deployment is based on changesets, which means that only files that changed since the last deployment are uploaded. An SSH action which performs the following tasks on your server:
- copies the
deploy-cache/
folder to thereleases/$REVISION
folder - changes the
current/
symlink so that it points toreleases/$REVISION
- clears old releases – by default Buddy will keep the last 10 of them, allowing for a quick rollback if required.
- copies the
Environment variables
All access data that you provide during the atomic deployment configuration is saved in the pipeline as encrypted environment variables. These variables are used in both actions, so in case you need to change the access data, you just have to edit the variables.
Image loading...
Editing atomic deployment
Atomic deployments in Buddy can be easily edited. The template's logic is hardcoded in the SSH action: there you can manage previous versions, configure rollbacks, and set the folder to the proper release. The scripts can be freely modified by defining your own rules.
Image loading...
The pipeline with the atomic template can be modified as well. For example, you can compile assets and test code for errors before the deployment, and send notifications using the selected messaging service:
Image loading...
Last modified on Sep 23, 2024