Notify Shipyrd from the Docker container

Run the Shipyrd gem inside a container. Same hook commands as the Ruby gem, no Ruby toolchain on the host.

What it does

ghcr.io/shipyrd/shipyrd-gem is a thin image that runs the shipyrd CLI. It reads the same KAMAL_* environment variables as the Ruby gem and posts to Shipyrd’s API on your behalf. From the hook’s perspective, you’re shelling out to shipyrd pre-deploy / shipyrd post-deploy.

Setup

  1. Make sure Docker is available wherever your deploys run from.

  2. Define a wrapper function (in your shell profile, a hook helper, or inline in the hook script):

    shipyrd() {
      docker run --rm \
        --env-file <(env | grep -E '^(KAMAL_|SHIPYRD_)') \
        ghcr.io/shipyrd/shipyrd-gem /shipyrd/bin/"$@"
    }
    

    The --env-file <(env | grep ...) line forwards any KAMAL_* and SHIPYRD_* variables into the container — that’s where the gem reads its inputs.

  3. Create Bash hooks that call the wrapper:

    #!/usr/bin/env bash
    # .kamal/hooks/pre-deploy
    shipyrd pre-deploy
    
    #!/usr/bin/env bash
    # .kamal/hooks/post-deploy
    shipyrd post-deploy
    
    chmod +x .kamal/hooks/pre-deploy .kamal/hooks/post-deploy
    
  4. Make sure SHIPYRD_API_KEY is in the deploying shell’s environment (or in .kamal/secrets).

  5. Deploy.

    kamal deploy
    

Verify it worked

Watch Kamal’s output for the hook lines. The first run will pull the container image (a few seconds); subsequent runs are instant. The deploy appears in your Shipyrd timeline once post-deploy runs.