Skip to Content
āš ļø Dockflow is currently under development. Bugs may occur. Please report any issues on GitHub.

Hooks

Hooks allow you to run custom scripts at specific points during deployment.

Available Hooks

HookLocationTiming
pre-buildCI runnerBefore Docker images are built
post-buildCI runnerAfter Docker images are built
pre-deployServerBefore Swarm stack deployment
post-deployServerAfter successful deployment

Setup

Create shell scripts in .deployment/hooks/:

      • pre-build.sh
      • post-build.sh
      • pre-deploy.sh
      • post-deploy.sh

All hooks are optional. If a hook file doesn’t exist, it is skipped.

Jinja2 Templating

Hooks are rendered with Jinja2 before execution. You can use any Ansible variable:

#!/bin/bash echo "Deploying {{ project_name }} version {{ version }} to {{ env }}" # Access environment variables DATABASE_URL="{{ lookup('env', 'DATABASE_URL') }}"

Examples

Pre-build: Generate assets

#!/bin/bash echo "Generating static assets..." npm run build:assets

Post-build: Security scan

#!/bin/bash echo "Running security scan..." docker scan {{ project_name }}:{{ version }} || true

Pre-deploy: Database backup

#!/bin/bash echo "Creating database backup before deployment..." pg_dump $DATABASE_URL > /backups/pre-deploy-{{ version }}.sql

Post-deploy: Notify team

#!/bin/bash curl -X POST "https://hooks.slack.com/services/xxx" \ -H "Content-Type: application/json" \ -d '{"text":"Deployed {{ project_name }} {{ version }} to {{ env }}"}'

Configuration

Hooks are enabled by default. Configure in .deployment/config.yml:

hooks: enabled: true # Enable/disable all hooks (default: true) timeout: 300 # Timeout per hook in seconds (default: 300)

If a hook fails, the deployment continues with a warning. Hooks do not block deployments.