Contents

Build & Deploy Hooks

The Build & Deploy Process

Build and deploy hooks take place at very specific points in both the build and deploy processes.

Build Hooks

Your app's engine builds and prepares your app's runtime and code. It's possible to include "extra steps" in this process. These are configured in the run.config section of your boxfile.yml.

extra_steps

extra_steps run after your app's runtime is built, but before the runtime is packaged for use.

run.config:
  extra_steps:
    - 'yarn install'
    - 'bower install'

Important Things to Know About Extra Steps

  • Environment variables are not available during the build process.
  • extra_steps do not have access to data services.
  • Code is fully writable.

Deploy Hooks

Deploy hooks run as apps are being deployed either to a dry-run or live app.

Important Things to Know About Deploy Hooks

  • Environment variables are available to deploy hooks.
  • Deploy hooks have access to running data services.
  • Code is writable during transform hooks, but read-only once transforms are complete.

transform

transform hooks run on all web and worker nodes just before their filesystems are locked down and made read-only. Any code modification dependent on environment variables must be run as a transform.

deploy.config:
  transform:
    - 'if [ "$ENV" = "prod" ]; then mv config-prod.yml config.yml; fi'

before_live

before_live hooks run on a new node before it starts accepting live requests. These are unique to each component, so Nanobox needs to know on which each will run. In multi-node components, these only run on a single node.

deploy.config:
  before_live:
    web.site:
      - 'bundle exec rake clear-cache'
      - 'echo I\'am ready to go'
    worker.jobs:
      - 'bundle exec check-queue'

before_live_all

before_live_all hooks are the same as before_live hooks, but they run on all new nodes in a multi-node component. These are useful when you need to modify the contents of writable directories.

deploy.config:
  before_live_all:
    web.site:
      - 'bundle exec prime-local-cache'
      - 'bundle exec register-host'

after_live

after_live hooks run on a new node after it starts accepting live requests. These are unique to each component, so Nanobox needs to know on which each will run. In multi-node components, these only run on a single node.

deploy.config:
  after_live:
    web.site:
      - 'bundle exec rake prime-cache'
      - 'echo "I am working"'
    worker.jobs:
      - 'bundle exec start-queue'

after_live_all

after_live_all hooks are the same as after_live hooks, but they run on all new nodes in a multi-node component. These are useful when you need to modify the contents of writable directories.

deploy.config:
  after_live_all:
    web.site:
      - 'bundle exec prime-local-cache'
      - 'bundle exec register-host'

Reach out to help@nanobox.io and we'll try to help.