lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
3.05k stars 174 forks source link

How to enable caddy-docker-proxy in a new build? #641

Closed wsw70 closed 4 months ago

wsw70 commented 4 months ago

I use caddy-docker-proxy successfully with my services using labels in their docker-compose files to configure Caddy on the fly. Everything works.

I now need to add an extra plugin to caddy (github.com/caddy-dns/ovh) and therefore build a new image with both github.com/lucaslorentz/caddy-docker-proxy/v2 and github.com/caddy-dns/ovh. I tried to do it in two different ways

Both ultimately create a new /user/bin/caddy in my Dockerfile (the example below is the latter approach)

FROM caddy:2
RUN /usr/bin/caddy \
    add-package \ 
    github.com/lucaslorentz/caddy-docker-proxy/v2 \
    github.com/hairyhenderson/caddy-teapot-module \
    github.com/caddy-dns/ovh
CMD ["caddy", "docker-proxy"]    # I tried with and without this line

When running this image, I just get the following short log:

INF | ts=1720366580.7163107 msg=using config from file file=/etc/caddy/Caddyfile 
INF | ts=1720366580.7168071 msg=adapted config to JSON adapter=caddyfile 

When checking the compiled modules from within the running container with caddy list-modules I get the expected extra three.

Non, with the original github.com/lucaslorentz/caddy-docker-proxy/v2 I get plenty of messages telling me which contained were automatically parsed and added to the configuration:

INF | ts=1720365865.266318 logger=docker-proxy msg=Swarm is available new=false 
INF | ts=1720365865.3979893 logger=docker-proxy msg=New Caddyfile caddyfile={
    admin 0.0.0.0:2015
    email REDACTED
    log {
        level ERROR
    }
}
(authenticate-with-authelia) {
    @forceAuth {
(...)

My question: is there anything special I need to do enable github.com/lucaslorentz/caddy-docker-proxy/v2?

francislavoie commented 4 months ago

See the README: https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov-file#custom-images

wsw70 commented 4 months ago

See the README: https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov-file#custom-images

This is where I came from.

I just found the issue with was a mistake of mine: I thought I had the latest version of my image but I did not. It works great now.