caddy-docker-proxy icon indicating copy to clipboard operation
caddy-docker-proxy copied to clipboard

Failed to build caddy-docke-proxy/[email protected] on custom caddy docker build

Open rizary opened this issue 11 months ago • 8 comments

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.

rizary avatar Jan 27 '25 00:01 rizary

false alarm

rizary avatar Jan 27 '25 00:01 rizary

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 ?

LeVraiRoiDHyrule avatar Jan 31 '25 08:01 LeVraiRoiDHyrule

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

mihakrumpestar avatar Jan 31 '25 11:01 mihakrumpestar

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

rizary avatar Jan 31 '25 14:01 rizary

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?

jpbaril avatar Feb 09 '25 20:02 jpbaril

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

jpbaril avatar Feb 09 '25 21:02 jpbaril

Could we then make a new release?

mihakrumpestar avatar Feb 10 '25 17:02 mihakrumpestar

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.

polarathene avatar Mar 21 '25 01:03 polarathene