A production-ready Copier template for quickly setting up Traefik reverse proxy with Docker Compose.
- ⚡ Quick Setup: Generate a complete Traefik project in seconds
- 🔐 SSL/TLS Ready: Automatic HTTPS certificates with Let's Encrypt
- 🛡️ Security Built-in: Optional basic authentication with htpasswd
- 🌍 Multi-Environment: Separate configurations for development and production
- 📝 Customizable: Interactive prompts or pre-configured answers file
- 🐳 Docker Native: Docker Compose configurations ready to deploy
- 📊 Dashboard Access: Traefik dashboard with configurable domains
- 🔄 Updatable: Use
copier updateto sync with template changes
- Python 3.7+ (for Copier)
- Docker and Docker Compose
- Basic understanding of Traefik and Docker
pip install copier
# or for isolated installation
pipx install copiercopier copy gh:YOUR_USERNAME/traefik-template ./my-traefik-projectYou'll be prompted to answer:
- Project name
- Development and production dashboard domains
- Email for Let's Encrypt
- Traefik version
- Basic auth configuration (optional)
- Log level
copier copy gh:YOUR_USERNAME/traefik-template ./my-traefik-project \
--data-file ./example-answers.ymlcopier copy /path/to/traefik-template ./my-traefik-projectAfter running Copier, you'll get a complete project with:
my-traefik-project/
├── docker-compose.common.yaml # Shared Traefik service configuration
├── docker-compose.devel.yaml # Development environment setup
├── docker-compose.prod.yaml # Production environment setup
├── .env # Environment variables
├── .gitignore # Git ignore rules
├── README.md # Project-specific documentation
├── setup.sh # Setup script (auto-executed)
├── data/
│ ├── acme.json # Let's Encrypt certificates (auto-created)
│ └── usersfile # Basic auth credentials (if enabled)
└── traefik/
├── traefik.yml # Main Traefik configuration
└── dynamic/ # Dynamic configuration directory
| Variable | Description | Default | Required |
|---|---|---|---|
project_name |
Name of your Traefik project | traefik-proxy |
Yes |
traefik_dashboard_host_devel |
Development dashboard domain | traefik.localhost |
Yes |
traefik_dashboard_host_prod |
Production dashboard domain | traefik.example.com |
Yes |
traefik_acme_email |
Email for Let's Encrypt | admin@example.com |
Yes |
traefik_version |
Traefik Docker image version | v2.11 |
Yes |
create_auth_user |
Create basic auth user? | true |
Yes |
auth_username |
Basic auth username | admin |
If auth enabled |
auth_password |
Basic auth password | - | If auth enabled |
log_level |
Logging level | INFO |
Yes |
Create a YAML file with your answers:
# my-answers.yml
project_name: company-traefik
traefik_dashboard_host_devel: traefik.local.dev
traefik_dashboard_host_prod: traefik.company.com
traefik_acme_email: devops@company.com
traefik_version: v2.11
create_auth_user: true
auth_username: admin
auth_password: secure-password-here
log_level: INFOThen use it:
copier copy gh:YOUR_USERNAME/traefik-template ./project \
--data-file my-answers.ymlWhen the template is updated, you can sync your project:
cd my-traefik-project
copier updateCopier will:
- Show you what has changed in the template
- Ask if you want to update each changed file
- Preserve your customizations where possible
These files are processed by Jinja2 templating engine:
docker-compose.common.yaml.jinja→ Docker Compose base configurationtraefik/traefik.yml.jinja→ Main Traefik configurationREADME.md.jinja→ Generated project READMEsetup.sh.jinja→ Post-generation setup script.env.jinja→ Environment variables file
These files are copied as-is:
docker-compose.devel.yaml→ Development environmentdocker-compose.prod.yaml→ Production environment.gitignore→ Git ignore rules
copier.yml→ Template metadata and questionsexample-answers.yml→ Example answers file for reference
README.md→ This file (template documentation)QUICKSTART.md→ Quick start guideUSAGE.md→ Detailed usage instructionsTEMPLATE.md→ Template structure documentationPUBLISHING.md→ Publishing guidelinesSETUP-SUMMARY.md→ Setup summary reference
# Test generating a project
copier copy . /tmp/test-project
# Check the generated files
cd /tmp/test-project
ls -la- Edit template files (
.jinjafiles) or configuration (copier.yml) - Test locally using the command above
- Commit and push changes
- Users can update their projects with
copier update
Edit copier.yml and add your question:
new_variable:
type: str
help: "Description of what this does"
default: "default-value"
validator: "{% if not new_variable %}Required{% endif %}"Then use it in your templates: {{ new_variable }}
# Create project
copier copy . ./my-dev-traefik --data project_name=dev-traefik
# Start development environment
cd my-dev-traefik
docker-compose -f docker-compose.common.yaml -f docker-compose.devel.yaml up -d
# Access dashboard at http://traefik.localhost (or your configured domain)# Create project with production answers
copier copy . ./prod-traefik --data-file prod-answers.yml
# Deploy to production
cd prod-traefik
docker-compose -f docker-compose.common.yaml -f docker-compose.prod.yaml up -d# Create separate projects for each environment
copier copy . ./traefik-staging --data-file staging-answers.yml
copier copy . ./traefik-production --data-file production-answers.yml- Passwords: Never commit
.envfiles or answers files with real passwords to version control - ACME Certificates: The
data/acme.jsonfile contains private keys - keep it secure - Basic Auth: Use strong passwords for production environments
- Dashboard Access: Always enable authentication for production dashboards
- Domains: Use proper DNS configuration for production domains
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Test the template generation
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
[Specify your license here]
Solution: Install Copier with pip install copier or pipx install copier
Solution: The setup script automatically sets correct permissions. If needed, run:
chmod 600 data/acme.jsonSolution:
- Check if domain resolves correctly
- For development, add to
/etc/hosts:127.0.0.1 traefik.localhost - Verify Docker containers are running:
docker ps
Solution:
- Verify email address is correct
- Ensure domain points to your server's public IP
- Check Traefik logs:
docker logs <traefik-container>
If you find this template helpful, please consider:
- Starring the repository ⭐
- Sharing it with others
- Reporting issues or suggesting improvements
Made with ❤️ for the DevOps community