This project provides a preconfigured development environment for building and testing Traefik plugins in Local Plugins mode.
It is based on a VS Code Dev Container and a docker-compose setup that runs Traefik, a test service (whoami), and your local plugin together.
The goal of this project is to offer a consistent, reproducible, and convenient environment for Traefik plugin development, supporting both local unit tests and integration tests with a running Traefik instance.
This configuration enables:
- Development of Traefik plugins in Go with full IDE support (IntelliSense, linting, debugging).
- Automated provisioning of a Traefik test setup with the
whoamiservice viadocker compose. - Fast development feedback loop through tasks for starting, restarting, and viewing logs.
- Dev Container (VS Code)
Contains the Go toolchain, Delve debugger, and additional tools for plugin development. - Traefik Container
Loads the plugin in Local Plugins mode and exposes it via a configured router. - Whoami Container
Minimal HTTP test service to validate plugin behavior.
Traefik plugins in Local Plugins mode are not shipped as precompiled Go binaries.
Instead, Traefik loads the plugin source code at runtime and interprets it using Yaegi.
Therefore, a Go installation inside the Traefik container is not required for execution.
However, having a Go toolchain in the development environment is recommended for:
-
Running Unit Tests
Test plugin logic in isolation from Traefik (go test ./...) to significantly reduce the feedback loop. -
Modern Development Tooling
Code completion, navigation, static analysis (go vet,staticcheck), and refactoring tools are readily available. -
Dependency Management
Commands likego mod tidykeepgo.modandgo.sumconsistent, preventing runtime errors when Traefik loads the plugin. -
Quality Assurance
Local tests and static analysis help catch issues early and improve long-term maintainability.
Conclusion:
The Go installation in the Dev Container exists solely for development and quality assurance.
Traefik itself does not require Go to execute Local Plugins.
- VS Code: Open the project in VS Code and select “Reopen in Container”.
- Start Traefik: Run the VS Code task
compose up. - Verify functionality:
The response should contain the HTTP header
curl -i -H "Host: demo.localhost" http://localhost:8080/X-Plugin: Hello. - Change code & retest:
After modifying the plugin code, run the VS Code taskcompose restart traefikand repeat the test command.
- Docker and Docker Compose
- Visual Studio Code with the Dev Containers Extension
- Shared project directories in Docker Desktop (on Windows/macOS)