How to build traefik v2 docker image completely

Hi
I've developed a bit on traefik source and now I want my image of traefik. There are currently 3 dockerfiles in the root: Dockerfile, build.Dockerfile, and exp.Dockerfile. (There's also one in the webui folder)

What I can't seem to achieve is that I can't make a final docker image! I tried make binary but that doesn't create docker image.
In fact, I don't get what build.Dockerfile does. It just installs dependencies and then copies the whole working directory to the image, but no output, no go building, no binary file, nothing!

The docker just finishes its work, then the scripts/make.sh generate binary will run and that alone builds the final binary to dist/traefik. The build.Dockerfile doesn't make any sense to me!

The second problem is that I can't build its dashboard to be inside of that docker container and with what config can I bring that up. The Dockerfile in root folder just copies traefik binary and the Dockerfile in webui just creates some files in static folder, but these two doesn't seem to be connected, like the official traefik image.

(By the way, exp.Dockerfile is also ambiguous to me!)

I'd be glad if anyone could help me with a complete walkthrough on how to build our own version of traefik, dockerize it (both development and production, so that it's usable in CI/CD in staging and production environment), and put webui in it (and how to access this through traefik).

Thanks.

Hello,

Take a look to the Makefile: https://github.com/containous/traefik/blob/14bdc0e57a272d616dcd80905303ec5417ac0842/Makefile#L107

1 Like

Yeah That's a good way for production env!

If you could provide complete development build, I'd be very thankful.
And By development build, I'm currently using go build ./cmd/traeifk/ and this builds the traefik binary for me and I run it by ./traefik --configFile=my-conf.toml. What it lacks, as far as I noticed, is its dashboard, but there's probably more to it (Like the CRD of my custom middleware which is not currently applied). I want the logical way of doing it.

Plus, I'd be very glad if you could explain what does that exp.Dockerfile do!

Thanks

To build Traefik with the WebUI:

rm -rf static/ autogen/
make generate-webui
go generate
go build ./cmd/traeifk/

or

# for Linux only
rm -rf static/ autogen/
make binary

The Dockerfiles:

.
ā”œā”€ā”€ build.Dockerfile (1)
ā”œā”€ā”€ Dockerfile (2)
ā”œā”€ā”€ exp.Dockerfile (3)
ā”œā”€ā”€ docs
ā”‚   ā”œā”€ā”€ check.Dockerfile (4)
ā”‚   ā””ā”€ā”€ docs.Dockerfile (5)
ā””ā”€ā”€ webui
    ā””ā”€ā”€ Dockerfile (6)

(1): used to build the binary and run integration tests. It contains Go, linting tool, release tool, ...
(2): used to build a Docker image with the target build-image
(3): used to build the experimental images. Those images are built by the DockerHub auto-build
(4): used to check the documentation (linting and verify links)
(5): used to build the documentation
(6): used to build the web-ui files

2 Likes

Just to add some (may be obvious) relevant bits, for anybody searching later: