Documentation Index
Fetch the complete documentation index at: https://mintlify.com/traefik/traefik/llms.txt
Use this file to discover all available pages before exploring further.
Building and Testing Traefik
This guide will help you compile your own Traefik binary from source and run the test suite locally.Prerequisites
Before you begin, ensure you have the following tools installed:Required Tools
- Docker - For building images and running integration tests
make- Build automation tool- Go - Go programming language (check
.go-versionfile for required version) - misspell - Spell checker for code
- shellcheck - Shell script linter
Docker Desktop Users: If you’re using Docker Desktop, you’ll also need Tailscale for certain integration tests.
Verify Installation
Check that your tools are properly installed:Environment Setup
Clone the Repository
Configure Go Environment
Set yourGOPATH and PATH environment variables:
Verify Environment
Rungo env to verify your setup:
Building Traefik
Generate WebUI Assets
Traefik includes a web UI that needs to be built first:Build the Binary
Now you can build the Traefik binary:- Runs code generation (
make generate) - Generates WebUI assets (
make generate-webui) - Compiles the binary with version information
The build process uses
CGO_ENABLED=0 to create a static binary that doesn’t depend on C libraries.Build Output
After building, you’ll find the executable in thedist directory:
Platform-Specific Builds
Build for specific platforms:Quick Build (Development)
For faster development iterations, use the default target:make generate and make binary but skips WebUI regeneration if already built.
Running Tests
Test Suite Overview
Traefik has three main test suites:- Unit Tests - Fast tests for individual packages
- Integration Tests - Tests with real infrastructure (Docker, Kubernetes, etc.)
- WebUI Unit Tests - Tests for the web interface
Run All Tests
test-ui-unit, test-unit, and test-integration.
Unit Tests
Run only the unit tests:Integration Tests
Run integration tests (requires Docker):Test Duration: Integration tests can take 20+ minutes as they spin up real infrastructure.
Pull Required Images
To avoid timeouts, pull Docker images before running integration tests:Run Specific Tests
Run a specific test suite or test:WebUI Tests
Run WebUI unit tests:Gateway API Conformance Tests
Test Kubernetes Gateway API compatibility:This requires building a Docker image first with
make build-image-dirty.Knative Conformance Tests
Test Knative compatibility:Code Validation
Linting
Run the linter using golangci-lint:.golangci.yml, including:
gofumpt- Stricter gofmtgci- Import organizationgovet- Go vet checkserrcheck- Error handling verification
File Validation
Validate code and documentation:- Misspellings in code and docs
- Shell script syntax
- Vendor dependencies
Complete Validation
Run all validation checks:make lint and make validate-files.
Pre-Commit Checklist
Before submitting a pull request, run these commands locally:Building Docker Images
Build Development Image
Build a local Docker image for testing:- Cleans the WebUI static directory
- Builds binaries for linux/amd64 and linux/arm64
- Creates a Docker image tagged
traefik/traefik:latest
Quick Image Build
If you’ve already built the WebUI:Multi-Architecture Images
Build for multiple architectures:Code Generation
Generate Configuration Docs
github.com/traefik/genconf.
Generate CRD Resources
- Kubernetes CRD clientset
- CRD manifest files
Code Formatting
Format your code before committing:gofmt with the -s flag for simplification.
Docker Desktop + Tailscale Setup
If you’re using Docker Desktop, some integration tests require Tailscale:Create Auth Key
Create a
tailscale.secret file in the integration directory with a Tailscale auth key (ephemeral, reusable recommended).Troubleshooting
Build Fails
- Ensure Go version matches
.go-version - Check that
GOPATHis set correctly - Verify all dependencies are installed
Tests Timeout
- Run
make pull-imagesbefore integration tests - Check Docker is running and has sufficient resources
- For specific tests, use
TESTFLAGSto run a subset
Linter Errors
- Run
make fmtto auto-format code - Check
.golangci.ymlfor specific linter rules - Fix errors one by one or disable specific rules if appropriate
Next Steps
Now that you can build and test Traefik:- Review the Contribution Guidelines for code standards
- Pick an issue to work on
- Make your changes and run the validation steps
- Submit a pull request!