Skip to main content

Overview

Woodpecker CI is a lightweight, cloud-native continuous integration and deployment system built on Docker. This document covers the deployment and configuration of Woodpecker CI using Docker Compose with Traefik as a reverse proxy.

Service Details

Architecture

The deployment consists of three main components:
  1. Woodpecker Server: The core service that manages the UI, API, and orchestrates CI jobs
  2. Woodpecker Agent: Executes CI jobs in containers
  3. PostgreSQL Database: Stores all Woodpecker CI data

Prerequisites

  • Docker Engine (24.0+)
  • Docker Compose v2
  • Traefik reverse proxy configured and running
  • External networks: woodpecker-net and traefik-net
  • GitHub OAuth application
  • DNS configured for ci.trymondo.com

Configuration Preparation

GitHub OAuth Setup

  1. Create a GitHub OAuth application at https://github.com/settings/applications/new
  2. Set the callback URL to https://ci.trymondo.com/login
  3. Note the Client ID and Client Secret for your .env file

Environment Variables

Create a .env file with the following variables:
Generate a secure, random string for WOODPECKER_AGENT_SECRET. This is used to authenticate agents with the server.
You can generate a secure random string with:

Deployment Configuration

Docker Compose File

Network Configuration

Before deployment, ensure the required networks exist:

Deployment Instructions

  1. Create the deployment directory:
  2. Create the docker-compose.yml and .env files:
  3. Deploy the service:
  4. Verify all services are running:

Traefik Integration Details

The Woodpecker server is configured with the following Traefik settings:
  • Host Rule: ci.trymondo.com
  • Entrypoints: websecure (HTTPS on port 443), web (HTTP on port 80 with redirect to HTTPS)
  • TLS: Enabled with production certificate resolver
  • Backend Port: 8000 (Woodpecker Web UI)
  • Middleware: HTTP to HTTPS redirect for enhanced security

Pipeline Configuration

Basic .woodpecker.yml Example

Create a .woodpecker.yml file in the root of your GitHub repository:

Secrets Management

To add secrets to your Woodpecker CI projects:
  1. Navigate to your repository in the Woodpecker UI
  2. Go to Settings > Secrets
  3. Add required secrets (e.g., docker_username, docker_password)

Scaling and Performance

Additional Agents

To scale out CI capacity, you can add more agents:

Resource Constraints

For improved stability, consider adding resource constraints:

Maintenance

Backup Strategy

Back up Woodpecker CI regularly:
  1. Database backup:
  2. Volume backup using Restic/Backrest:
    • woodpecker-server-data (contains server state)
    • woodpecker-db-data (contains database files)

Updates

To update Woodpecker CI:
  1. Update the image tags in docker-compose.yml
  2. Apply the update:
  3. Check logs for any issues:

Troubleshooting

Server Startup Issues

If the server fails to start:
  1. Check environment variables:
  2. Verify database connection:

Agent Connection Problems

If agents can’t connect to the server:
  1. Check agent logs:
  2. Verify agent secret is consistent between server and agent
  3. Check network connectivity between containers:

GitHub Integration Issues

If GitHub integration is not working:
  1. Verify OAuth callback URL is correctly set to https://ci.trymondo.com/login
  2. Check GitHub client ID and secret in environment variables
  3. Examine server logs for OAuth-related errors:

Security Considerations

  • Agent Secret: Use a strong, randomly generated secret for agent authentication
  • Admin Access: Limit admin access to specific GitHub usernames
  • Docker Socket: The agent has access to the Docker socket, which grants significant privileges
  • HTTPS: Enforce HTTPS-only access through Traefik
  • Network Isolation: Use separate networks for communication between services

Additional Resources

Pipeline Examples

Node.js Application

Docker Build and Push

Multi-stage Pipeline with Approval