Skip to content

Building and Testing

Compile and Test Your Own Traefik!

You want to build your own Traefik binary from the sources? Let's see how.


You need: - Docker - make - Go - misspell - shellcheck - Tailscale if you are using Docker Desktop

Source Directory

It is recommended that you clone Traefik into the ~/go/src/ directory. This is the official golang workspace hierarchy that will allow dependencies to be properly resolved.


Set your GOPATH and PATH variable to be set to ~/go via:

export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin

For convenience, add GOPATH and PATH to your .bashrc or .bash_profile

Verify your environment is setup properly by running $ go env. Depending on your OS and environment, you should see an output similar to:

## ... and the list goes on

Build Traefik

Once you've set up your go environment and cloned the source repository, you can build Traefik.

$ make binary
SHA: 8fddfe118288bb5280eb5e77fa952f52def360b4 cheddar 2024-01-11_03:14:57PM
CGO_ENABLED=0 GOGC=off GOOS=darwin GOARCH=arm64 go build  -ldflags "-s -w \
    -X \
    -X \
    -X" \
    -installsuffix nocgo -o "./dist/darwin/arm64/traefik" ./cmd/traefik

$ ls dist/

You will find the Traefik executable (traefik) in the ./dist directory.


Run unit tests using the test-unit target. Run integration tests using the test-integration target. Run all tests (unit and integration) using the test target.

$ make test-unit
GOOS=darwin GOARCH=arm64 go test -cover "-coverprofile=cover.out" -v ./pkg/... ./cmd/...
+ go test -cover -coverprofile=cover.out .
ok   0.005s  coverage: 4.1% of statements

Test success

For development purposes, you can specify which tests to run by using (only works the test-integration target):

Configuring Tailscale for Docker Desktop user

Create tailscale.secret file in integration directory.

This file need to contains a Tailscale auth key (an ephemeral, but reusable, one is recommended).

Add this section to your tailscale ACLs to auto-approve the routes for the containers in the docker subnet:

    "autoApprovers": {
      // Allow myself to automatically
      // advertize routes for docker networks
      "routes": {
        "": ["your_tailscale_identity"],
# Run every tests in the MyTest suite
TESTFLAGS=" TestAccessLogSuite" make test-integration

# Run the test "MyTest" in the MyTest suite
TESTFLAGS=" TestAccessLogSuite -testify.m ^TestAccessLog$" make test-integration