Failed to build caddy-docke-proxy/[email protected] on custom caddy docker build
Here's the error:
152.0 # github.com/lucaslorentz/caddy-docker-proxy/v2/docker
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client.go:14:51: undefined: types.ContainerListOptions
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client.go:17:35: undefined: types.Info
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client.go:37:80: undefined: types.ContainerListOptions
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client.go:53:64: undefined: types.Info
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client_mock.go:18:29: undefined: types.Info
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client_mock.go:26:74: undefined: types.ContainerListOptions
152.0 /go/pkg/mod/github.com/lucaslorentz/caddy-docker-proxy/[email protected]/docker/client_mock.go:61:58: undefined: types.Info
152.5 2025/01/27 00:18:37 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2025-01-27-0016.414000893
[+] Running 0/17 00:18:37 [FATAL] exit status 1
Here's my custom build:
FROM caddy:builder AS builder
RUN xcaddy build \
--with github.com/lucaslorentz/caddy-docker-proxy/v2 \
--with github.com/mholt/caddy-ratelimit \
--with github.com/caddy-dns/cloudflare \
--with github.com/WeidiDeng/caddy-cloudflare-ip \
--with github.com/porech/caddy-maxmind-geolocation \
--with github.com/caddyserver/transform-encoder \
--with github.com/hslatman/caddy-crowdsec-bouncer/http@main \
--with github.com/hslatman/caddy-crowdsec-bouncer/layer4@main \
--with github.com/mholt/caddy-l4
FROM caddy:latest
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
when I remove the caddy-docker-proxy, everything is good. Last time I use 2.8.4 is working fine. Buti when I upgrade to 2.9.1, i got this error. I use every image tag (builder, builder-alpine, 2.9.1-builder, etc) on docker hub and the result was the same.
false alarm
false alarm
I am having exactly the same error, I too am trying to install docker proxy + crowdsec bouncer modules. Can you tell how you fixed it ?
I am getting the same error.
Using:
RUN xcaddy build \
--with github.com/yroc92/postgres-storage \
--with github.com/caddy-dns/desec \
--with github.com/lucaslorentz/caddy-docker-proxy/v2 \
--with github.com/sablierapp/sablier/plugins/caddy=/sablier/plugins/caddy \
--with github.com/fabriziosalmi/caddy-waf=/caddy-waf \
--with github.com/hslatman/caddy-crowdsec-bouncer/http
false alarm
I am having exactly the same error, I too am trying to install docker proxy + crowdsec bouncer modules. Can you tell how you fixed it ?
You can see it in my PR #696
I'm puzzled. The above PR has been merged into main yet I still have that exact same error message when I try to create my custom image.
My Dockerfile is almost identical:
FROM caddy:builder AS builder
RUN xcaddy build \
--with github.com/lucaslorentz/caddy-docker-proxy/v2 \
--with github.com/hslatman/caddy-crowdsec-bouncer/http \
--with github.com/sablierapp/sablier/plugins/caddy \
--with github.com/caddy-dns/cloudflare
FROM caddy:latest
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
CMD ["caddy", "docker-proxy"]
So, what's wrong and how can I diagnose in more details?
Replying to myself.
It looks like the default behavior of the build process is not to use the latest code (commit) of the main branch but rather to use the code of the last officially released version, so 2.9.1, which released back in June 2024. Well, that's logical but I did not know that.
So to get the corrective code of last week's PR I had to specify the commit hash of that commit I wanted to include.
--with github.com/lucaslorentz/caddy-docker-proxy/v2@7c489f0e193efaf57aaaed07da9cc713c55054d1
Could we then make a new release?
This can be closed, there was a release in Feb 16 that builds fine.
So to get the corrective code of last week's PR I had to specify the commit hash of that commit I wanted to include.
--with github.com/lucaslorentz/caddy-docker-proxy/v2@7c489f0e193efaf57aaaed07da9cc713c55054d1
You should also be able to specify the branch name instead of the commit, like is shown in some of the modules in the example for the original issue description using @main.