Package: laebelmaker
LaebelmakerTool for generating Traefik labels. Written in Python.InstallationLaebelmaker is published on PyPI. You can use pip to install it:python3 -m pip install --user laebelmakerIt is recommended that you also install thedockermodule. You
can install both Laebelmaker and docker as its dependency with:python3 -m pip install --user laebelmaker[docker]This will allow Laebelmaker to use metadata of Docker images
to prevent redundant prompts from the user, e.g. when an image
exposes a single port.UsageLaebelmaker can be used to automatically generate Traefik labels
from various sources, such asdocker-compose.ymlfiles, running
Docker containers and user-given options.You can always consult the help menu for all features with short
(and hopefully clear) explanations:$ laebelmaker
usage: laebelmaker [-h] [-i] [-c NAME] [-f FORMAT] [FILES ...]

Generate Traefik labels

positional arguments:
  FILES                 list of Compose files to generate labels for

options:
  -h, --help            show this help message and exit
  -i, --interactive     use interactive mode
  -c NAME, --container NAME
                        generate labels for a given container on the system
  -f FORMAT, --format FORMAT
                        set output format, one of: [docker, none, yaml]ExamplesCLI Interactive Mode$ laebelmaker -i
Enter value for 'deploy name': myapp
Enter value for 'url': myapp.example.com
Enter value for 'port' (integer): 25565
Enter value for 'https redirection' (yes/No): no
--START GENERATED LABELS FOR 'myapp'--
traefik.enable=true
traefik.http.routers.myapp.rule=Host(`myapp.example.com`)
traefik.http.services.myapp.loadbalancer.server.port=25565
--END GENERATED LABELS FOR 'myapp'--With Compose YAML fileInvoking laebelmaker on a Docker Compose YAML file, the program will
prompt the user for different options, with the defaults given in
parentheses. This example also modifies the output format with-f yaml, which means the labels are immediately ready to be used
in a YAML file.$ laebelmaker -f yaml examples/docker-compose-testapp.yml
Found multiple services.
 1. testapp
 2. testapp-db
Service number to use (default 1): 1
Enter value for 'url': testapp.example.com/api
Enter value for 'https redirection' (yes/No): yes
Enter value for 'web entrypoint': https
Enter value for 'websecure entrypoint': https
Enter value for 'tls resolver': letsencrypt
--START GENERATED LABELS FOR 'testapp'--
  - traefik.enable=true
  - traefik.http.routers.testapp.rule=(Host(`testapp.example.com`) && PathPrefix(`/api`))
  - traefik.http.routers.testapp.entrypoints=https
  - traefik.http.routers.testapp-https.rule=(Host(`testapp.example.com`) && PathPrefix(`/api`))
  - traefik.http.routers.testapp-https.entrypoints=https
  - traefik.http.routers.testapp.middlewares=testapp-redir
  - traefik.http.middlewares.testapp-redir.redirectscheme.scheme=https
  - traefik.http.routers.testapp-https.tls=true
  - traefik.http.routers.testapp-https.tls.certresolver=letsencrypt
  - traefik.http.services.testapp.loadbalancer.server.port=80
--END GENERATED LABELS FOR 'testapp'--If an invalid file is given, Laebelmaker should hopefully print a
sensible error message.$ laebelmaker examples/invalid-image-tag.yml
Pulling image:
 ⠿ ubuntu:latestest Failed
Invalid image tag: 'ubuntu:latestest' in 'examples/invalid-image-tag.yml'.
Failed to produce output.
Try running: laebelmaker --helpTo-doGenerate Traefik labels using an interactive CLIGenerate Traefik labels using command-line optionsGenerate labels from existing service definitions (e.g. Docker Compose YAML files)Learn how to and publish this project to PyPiAdd combined Rule types (with logical operators)Add automated testsAdd support for TCP/UDP routers and servicesRemove pyyaml as a hard dependencyAdd local Traefik config as data source (e.g. for entrypoint and TLS resolver names)Add Dockerfile as a data sourceAdd K8s YAML as a data sourceAdd Docker Swarm YAML as a data sourceAdd more sophisticated Rule parsing (e.g. from a given URL)Something to think about:Expand out of Traefik into a more general use-caseCompatibility for Windows machinesGuidelines for developmentEase of use is a priorityUse sensible defaults without asking, when possibleWhen defaults are not possible, offer the user a sensible prefilled valueThe code should be as Pythonic as possibleUse type hints as much as possible to catch logical errorsLocal development setupFor local development, avirtual environmentis highly recommended. The following section will assume you installed a virtual
environment with thevenvmodule:python3 -m venv venvAll requirements for development are given inrequirements-dev.txt.
Install all of them before contributing. This is required forpre-commit.Before commiting, install pre-commit hooks for Git by running:pre-commit installThis will run the following programs to verify a commit:Black- code formattingMyPy- static type checkingPyLint- code lintingYou can install the Laebelmaker project locally inDevelopment Mode:python3 -m pip install -e .The project will be installed in the virtual environment but will remain editable.