Skip to main content

Overview

Dockhand’s Git integration enables automatic deployment of Docker Compose stacks directly from Git repositories. Connect to GitHub, GitLab, or any Git server and automatically sync changes, trigger deployments via webhooks, and maintain version-controlled infrastructure.

Key Features

  • Repository Management: Connect to any Git repository (GitHub, GitLab, Bitbucket, self-hosted)
  • Automatic Sync: Schedule periodic syncs to check for updates
  • Webhook Support: Instant deployments triggered by Git push events
  • Credential Management: Secure storage for SSH keys and access tokens
  • Multi-Stack Support: Deploy multiple stacks from a single repository
  • Branch Selection: Deploy from any branch (main, develop, feature branches)
  • Environment Files: Automatic .env file handling from repository

Repository Configuration

Creating a Git Repository Connection

  1. Navigate to GitRepositories
  2. Click Add Repository
  3. Configure the repository settings:

Authentication Methods

Dockhand supports multiple authentication methods:

SSH Key Authentication

HTTPS with Token

Public Repositories

Git Stacks

What are Git Stacks?

Git stacks are Docker Compose stacks that are automatically deployed from a Git repository. They maintain synchronization with the repository and can be configured for automatic updates.

Creating a Git Stack

Stack Deployment Process

When a Git stack is deployed, Dockhand:
  1. Clones or pulls the latest changes from the repository
  2. Checks out the specified branch
  3. Loads environment variables from the .env file (if specified)
  4. Applies stack variables from Dockhand’s variable management
  5. Runs docker compose up with the specified compose file
  6. Records deployment logs for audit and troubleshooting

Webhook Integration

GitHub Webhooks

  1. Get your webhook URL from Dockhand:
  2. In your GitHub repository, go to SettingsWebhooksAdd webhook
  3. Configure the webhook:
    • Payload URL: Your Dockhand webhook URL
    • Content type: application/json
    • Secret: Generate a secret in Dockhand and paste it here
    • Events: Select “Just the push event”

GitLab Webhooks

  1. In your GitLab project, go to SettingsWebhooks
  2. Configure the webhook:
    • URL: Your Dockhand webhook URL
    • Secret token: Your Dockhand webhook secret
    • Trigger: Check “Push events”
    • SSL verification: Enable for production

Webhook Security

Dockhand verifies webhook signatures to ensure authenticity:

Automatic Sync

Scheduled Synchronization

Configure automatic sync with cron expressions:

Sync Behavior

The scheduler implements intelligent sync behavior:

Environment Variables

Repository .env Files

Dockhand can automatically load environment variables from files in your repository:
Configure which file to use:

Stack Variable Override

Variables defined in Dockhand take precedence over repository files:
  1. Repository .env file (lowest priority)
  2. Stack-specific variables in Dockhand
  3. Environment variables set at deploy time (highest priority)

Manual Operations

Sync Repository

Manually trigger a sync to check for updates:
Response:

Deploy Stack

Manually deploy a Git stack:
The API uses Server-Sent Events (SSE) for real-time deployment progress:

Best Practices

Repository Structure

Security Recommendations

  1. Never commit secrets to your repository
  2. Use webhook secrets to verify authenticity
  3. Rotate credentials periodically
  4. Use read-only deploy keys when possible
  5. Enable SSL verification for webhooks
  6. Store sensitive env vars in Dockhand, not in repository files

Deployment Strategies

Blue-Green Deployments

Use Git branches for zero-downtime deployments:

Multi-Environment Setup

Troubleshooting

Common Issues

Authentication Failed

Webhook Not Triggering

  1. Check webhook secret matches in both GitHub/GitLab and Dockhand
  2. Verify webhook URL is accessible from the internet
  3. Check webhook delivery logs in your Git provider
  4. Ensure SSL certificate is valid (or disable verification for testing)

Stack Not Updating

Viewing Sync Logs

All sync operations are logged and can be viewed in the Schedule Executions page:

API Reference

Repository Endpoints

Stack Endpoints

Credential Endpoints