Stack Management
Git Stack Sync
Sync and deploy a Git-managed compose stack
POST
Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Finsys/dockhand/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Git stacks are compose stacks synchronized from Git repositories. This endpoint pulls the latest changes from the repository and redeploys the stack if changes are detected.Path Parameters
Git stack ID (not the stack name)
Response
Whether the sync operation succeeded
Whether the stack was redeployed (true only if changes were detected)
Error message if sync or deployment failed
Human-readable status message
Docker Compose deployment output (if deployed)
Latest Git commit hash after sync
Sync Behavior
- Check Status: Verifies stack isn’t already syncing
- Git Pull: Fetches latest changes from the configured branch
- Change Detection: Compares new commit hash with last deployed commit
- Deploy: If changes detected, runs
docker compose up -d - Skip: If no changes, returns success without deploying
The sync operation only redeploys if the Git commit hash has changed. If the repository is up-to-date, no deployment occurs.
Creating a Git Stack
Before syncing, you need to create a Git stack:Git Stack Configuration
Unique stack name
Git repository URL (HTTPS or SSH)
Git branch to track
Path to compose file in repository (relative to repo root)
Path to .env file in repository (optional)
Enable automatic syncing on a schedule
Cron expression for auto-sync schedule (default: 3 AM daily)
Git credential ID for private repositories (optional)
Enable webhook for push-triggered deploys
Secret for webhook verification (auto-generated if not provided)
Auto-Sync Schedules
Git stacks can automatically sync on a schedule:Common Cron Patterns
| Schedule | Cron Expression | Description |
|---|---|---|
| Every hour | 0 * * * * | At minute 0 of every hour |
| Daily at 3 AM | 0 3 * * * | At 3:00 AM every day |
| Twice daily | 0 3,15 * * * | At 3:00 AM and 3:00 PM |
| Every 6 hours | 0 */6 * * * | Every 6 hours |
| Weekly (Monday 3 AM) | 0 3 * * 1 | At 3:00 AM every Monday |
Webhook Integration
Enable webhooks to trigger sync on Git push events:- Enable webhook in Git stack settings
- Get webhook URL:
https://your-dockhand-instance.com/api/git/stacks/{id}/webhook - Configure in GitHub/GitLab: Add webhook URL with secret
GitHub Webhook Setup
- Go to repository Settings → Webhooks → Add webhook
- Payload URL:
https://your-dockhand-instance.com/api/git/stacks/5/webhook - Content type:
application/json - Secret: (use the webhook secret from stack configuration)
- Events: Select “Just the push event”
- Active: ✓
GitLab Webhook Setup
- Go to repository Settings → Webhooks
- URL:
https://your-dockhand-instance.com/api/git/stacks/5/webhook - Secret token: (use the webhook secret from stack configuration)
- Trigger: Select “Push events”
- Enable SSL verification: ✓
Repository Structure Example
Environment Variable Overrides
You can override environment variables without modifying the Git repository:Error Handling
404 Not Found
403 Forbidden
- User lacks
stacks:editpermission - User cannot access the stack’s environment
409 Conflict
500 Internal Server Error
- Git authentication failed
- Repository not accessible
- Invalid compose file syntax
- Network connectivity issues
Sync Status
Get the current sync status of a Git stack:Permissions
Requiresstacks:edit permission for the stack’s environment.
Related Endpoints
- Deploy Stack - Deploy a new stack with Git integration
- Update Stack - Update Git stack configuration
- Delete Stack - Remove a Git-synced stack
- List Stacks - View all stacks including Git-synced ones
