Build Scripts and Deploy Scripts
You can customize Hatchbox's deployment process with your own build scripts and deploy scripts.
Updated
Every application is different, so we've designed Hatchbox to be flexible to customize it to your application's needs.
These scripts run during deployment on the application servers, ie. servers with web, worker, cron, or app roles.
Pre-build Script
Use the pre-build script if you need to run anything before building the application. You might use the pre-build script to symlink directories, for example.
Build script
The build script is primarily used for installing dependencies, compiling assets, and running migrations.
Post-build script
The post-build script runs after your application dependencies are installed.
Post-deploy script
The post-deploy script runs after the deployment was successful. This is commonly used to notify services like Honeybadger of a successful deployment.
Failed deploy script
Hatchbox can run a script when a deployment fails. This can be useful for notifying an error monitoring service or chat app like Slack.
This script is run once on a server in your cluster.
Environment Variables
Scripts have access to several environment variables during the deployment:
DIR=/home/deploy/app
RELEASE_DIR=/home/deploy/app/releases/1234567890
RELEASE=1234567890
REVISION=commit-sha
LOG_ID=12345 # Hatchbox log ID
BRANCH=main
They also have server-specific variables. For example, migrations often need to be run on a single server, so we can run them on the CRON server only.
# A comma separated list of all roles for the current server
ROLES=web,cron,worker
# These will be set to true if the current server has the role
LOAD_BALANCER=true
WEB=true
CRON=true
WORKER=true
APP=true