Docker xcaddy can't build

1. The problem I’m having:

i have recently built a server from myself. previously i was hosting from my raspberry pi.
i am now looking to rebuild my custom docker image with a few plugins.
however, whenever i build it (no matter whether with docker build or docker compose build) i get a fatal error 2

dockerfile:

ARG CADDY_VERSION=2
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/lucaslorentz/caddy-docker-proxy/v2@v2.8.1 \
    --with github.com/caddy-dns/cloudflare \
    --with github.com/mholt/caddy-dynamicdns 

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

CMD ["caddy", "docker-proxy"]

here’s the log from when i run docker build from shortly before the Error:

#0 45.81 go: found github.com/Azure/go-ansiterm/winterm in github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161
#0 45.88 2023/04/01 18:49:00 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath 
#0 77.81 # go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig
#0 77.81 /go/pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace@v1.10.0/internal/otlpconfig/envconfig.go:84:13: undefined: envconfig.WithTLSConfig
#0 77.81 /go/pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace@v1.10.0/internal/otlpconfig/envconfig.go:85:13: undefined: envconfig.WithTLSConfig
#0 86.44 2023/04/01 18:49:41 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2023-04-01-1848.3643595957
#0 86.44 2023/04/01 18:49:41 [FATAL] exit status 2
------
failed to solve: executor failed running [/bin/sh -c xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2@v2.8.1     --with github.com/caddy-dns/cloudflare     --with github.com/mholt/caddy-dynamicdns]: exit code: 1

2. Error messages and/or full log output:

#0 45.81 go: found github.com/Azure/go-ansiterm/winterm in github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161
#0 45.88 2023/04/01 18:49:00 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath 
#0 77.81 # go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig
#0 77.81 /go/pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace@v1.10.0/internal/otlpconfig/envconfig.go:84:13: undefined: envconfig.WithTLSConfig
#0 77.81 /go/pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace@v1.10.0/internal/otlpconfig/envconfig.go:85:13: undefined: envconfig.WithTLSConfig
#0 86.44 2023/04/01 18:49:41 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2023-04-01-1848.3643595957
#0 86.44 2023/04/01 18:49:41 [FATAL] exit status 2
------
failed to solve: executor failed running [/bin/sh -c xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2@v2.8.1     --with github.com/caddy-dns/cloudflare     --with github.com/mholt/caddy-dynamicdns]: exit code: 1

3. Caddy version:

docker-compose building with xcaddy via a dockerfile:

ARG CADDY_VERSION=2
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/lucaslorentz/caddy-docker-proxy/v2@v2.8.1 \
    --with github.com/caddy-dns/cloudflare \
    --with github.com/mholt/caddy-dynamicdns 

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

CMD ["caddy", "docker-proxy"]

4. How I installed and ran Caddy:

a. System environment:

in a Docker Container on NixOS Linux on a Ryzen 7 2700x

b. Command:

docker build ./build-dockerfile/ --pull --no-cache

c. Service/unit/compose file:

dockerfile:

ARG CADDY_VERSION=2
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/lucaslorentz/caddy-docker-proxy/v2@v2.8.1 \
    --with github.com/caddy-dns/cloudflare \
    --with github.com/mholt/caddy-dynamicdns 

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

CMD ["caddy", "docker-proxy"]

d. My complete Caddy config:

not even getting to this step lol

5. Links to relevant resources:

Why are you building with CDP v2.8.1?

Try with v2.8.3 instead (the latest) – I just tried with that version, and it seems to work fine.

sorry, was out of home for a bit and my VPN back home (aforementioned raspi) was turned off

yes, that worked. thanks a lot!! :DD

(for anyone stumbling on this later: CDP is caddy-docker-proxy. i first thought it was a go library or similar lol)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.