Docs / Cloud & DevOps / Implementing Trunk-Based Development Workflow

Implementing Trunk-Based Development Workflow

By Admin · Jan 18, 2026 · Updated Apr 23, 2026 · 3 views · 3 min read

Managing trunk-based effectively is a crucial skill for any system administrator. This tutorial provides step-by-step instructions for git configuration, along with best practices for production environments.

Prerequisites

  • A Git repository for your project
  • A registered domain name (for public-facing services)
  • Basic familiarity with the Linux command line
  • Root or sudo access to the server
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)

Pipeline Configuration

The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.


# .github/workflows/deploy.yml
name: Deploy to Production
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: |
          docker build -t myapp:latest .
      - name: Deploy
        run: |
          ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'

Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.

Build and Test Setup

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.


# Set up deployment pipeline
mkdir -p /opt/myapp
cd /opt/myapp

# Create deployment script
cat << 'EOF' > deploy.sh
#!/bin/bash
set -euo pipefail
echo "Deploying version: $1"
docker pull myapp:$1
docker compose down
DOCKER_TAG=$1 docker compose up -d
echo "Deployment complete"
EOF
chmod +x deploy.sh

Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.

  • Enable automatic security updates for critical patches
  • Test your backup restore procedure monthly
  • Monitor disk space usage and set up alerts
  • Keep your system packages updated regularly
  • Review log files weekly for anomalies

Deployment Automation

Performance benchmarks show that properly tuned trunk-based can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.


# .github/workflows/deploy.yml
name: Deploy to Production
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: |
          docker build -t myapp:latest .
      - name: Deploy
        run: |
          ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'

Each line in the configuration serves a specific purpose. The comments explain the reasoning behind each setting, making it easier to customize for your specific use case.

Common Issues and Solutions

  • Connection timeout: Verify your firewall rules allow traffic on the required ports. Use ss -tlnp to confirm the service is listening on the expected port.
  • Service won't start: Check the logs with journalctl -xe -u trunk-based. Common causes include port conflicts, missing configuration files, or insufficient permissions.
  • High memory usage: Review the configuration for memory-related settings. Reduce worker counts or buffer sizes if running on a low-RAM VPS.

Next Steps

With trunk-based now set up and running, consider implementing monitoring to track performance metrics over time. Regularly review your configuration as your workload changes and scale resources accordingly.

Was this article helpful?