caddy-security icon indicating copy to clipboard operation
caddy-security copied to clipboard

breakfix: xcaddy go version mismatch

Open martijndierckx opened this issue 9 months ago • 9 comments

Describe the issue

I'm trying to use xcaddy to build caddy including caddy-security in my docker compose file. But i'm getting a GO version error.

Configuration

Dockerfile:

FROM caddy:builder AS builder
RUN xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/greenpau/caddy-security
FROM caddy:latest
RUN addgroup -S caddy && adduser -S -G caddy caddy
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
RUN setcap CAP_NET_BIND_SERVICE=+ep /usr/bin/caddy
WORKDIR /srv
RUN chown -R caddy:caddy /srv /data /config /etc/caddy
USER caddy
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

Version Information

Caddy: v2.9.1 = latest Caddy-security: v1.1.31 = latest

Build output

docker buildx create --use && docker buildx build --tag md/caddy --platform linux/amd64 .
zealous_hawking
[+] Building 26.0s (9/13)                                                                                                                                           
 => [internal] booting buildkit                                                                                                                                6.5s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                             5.5s
 => => creating container buildx_buildkit_zealous_hawking0                                                                                                     1.0s
 => [internal] load build definition from Dockerfile                                                                                                           0.0s
 => => transferring dockerfile: 498B                                                                                                                           0.0s
 => [internal] load metadata for docker.io/library/caddy:builder                                                                                               1.8s
 => [internal] load metadata for docker.io/library/caddy:latest                                                                                                1.8s
 => [internal] load .dockerignore                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                0.0s
 => [builder 1/2] FROM docker.io/library/caddy:builder@sha256:c1e258b449a2deaab94f90330450fcfe8c3e0b6f0891f28a704c749f43825877                                 4.7s
 => => resolve docker.io/library/caddy:builder@sha256:c1e258b449a2deaab94f90330450fcfe8c3e0b6f0891f28a704c749f43825877                                         0.0s
 => => sha256:27240b2158b54e9a1c7399976b5ecf43f84ecee5fa358bbdbd9e33ab5376df16 402B / 402B                                                                     0.4s
 => => sha256:836e6b44f0011f60d37d379ae6d4cd14d260bb1c0d59b2f78872dc4ce422dc8c 1.84MB / 1.84MB                                                                 0.3s
 => => sha256:6ec853fc7b6998e009b618593e9e453c8705042bba4f8be9ec7b69436fd1138e 5.94MB / 5.94MB                                                                 0.6s
 => => sha256:b5acb76e968064ef973541dc9568ddcc77a62715cc268ca0282004a1349897d8 126B / 126B                                                                     0.1s
 => => sha256:6ca661eb024f09b95cfdf77781effc26400df52d97566fbd0fd4d45a67c3a3e6 74.06MB / 74.06MB                                                               1.8s
 => => sha256:8833042f23b55b241bbb6352d36795dec58ceae053fa5e7f68b7da568ede5a71 294.38kB / 294.38kB                                                             0.2s
 => => extracting sha256:8833042f23b55b241bbb6352d36795dec58ceae053fa5e7f68b7da568ede5a71                                                                      0.0s
 => => extracting sha256:6ca661eb024f09b95cfdf77781effc26400df52d97566fbd0fd4d45a67c3a3e6                                                                      2.0s
 => => extracting sha256:b5acb76e968064ef973541dc9568ddcc77a62715cc268ca0282004a1349897d8                                                                      0.0s
 => => extracting sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1                                                                      0.0s
 => => extracting sha256:6ec853fc7b6998e009b618593e9e453c8705042bba4f8be9ec7b69436fd1138e                                                                      0.1s
 => => extracting sha256:836e6b44f0011f60d37d379ae6d4cd14d260bb1c0d59b2f78872dc4ce422dc8c                                                                      0.0s
 => => extracting sha256:27240b2158b54e9a1c7399976b5ecf43f84ecee5fa358bbdbd9e33ab5376df16                                                                      0.0s
 => [stage-1 1/6] FROM docker.io/library/caddy:latest@sha256:cd261fc62394f1ff0b44f16eb1d202b4e71d5365c9ec866a4f1a9c5a52da9352                                  1.2s
 => => resolve docker.io/library/caddy:latest@sha256:cd261fc62394f1ff0b44f16eb1d202b4e71d5365c9ec866a4f1a9c5a52da9352                                          0.0s
 => => sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1 32B / 32B                                                                       0.2s
 => => sha256:b8a5ec3997960cd1a012bd930deed7c259404b2549954aba8b2d00b051d21992 14.38MB / 14.38MB                                                               0.6s
 => => sha256:6fd3ccaa8d5edd218ae72a9d5b10d99a1bbc199ae1bc7a6973e2627558db54a5 7.49kB / 7.49kB                                                                 0.2s
 => => sha256:9c63ec053486e151235fc0a8df56f704fb01beec9cbd3d5d8ead48a7cf9cec56 359.23kB / 359.23kB                                                             0.4s
 => => sha256:0a9a5dfd008f05ebc27e4790db0709a29e527690c21bcbcd01481eaeb6bb49dc 3.63MB / 3.63MB                                                                 0.5s
 => => extracting sha256:0a9a5dfd008f05ebc27e4790db0709a29e527690c21bcbcd01481eaeb6bb49dc                                                                      0.1s
 => => extracting sha256:9c63ec053486e151235fc0a8df56f704fb01beec9cbd3d5d8ead48a7cf9cec56                                                                      0.1s
 => => extracting sha256:6fd3ccaa8d5edd218ae72a9d5b10d99a1bbc199ae1bc7a6973e2627558db54a5                                                                      0.0s
 => => extracting sha256:b8a5ec3997960cd1a012bd930deed7c259404b2549954aba8b2d00b051d21992                                                                      0.2s
 => => extracting sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1                                                                      0.0s
 => [stage-1 2/6] RUN addgroup -S caddy && adduser -S -G caddy caddy                                                                                           0.2s
 => ERROR [builder 2/2] RUN xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/greenpau/caddy-security                                     12.8s
------                                                                                                                                                              
 > [builder 2/2] RUN xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/greenpau/caddy-security:                                                 
#0 0.114 2025/03/26 13:23:24 [INFO] absolute output file path: /usr/bin/caddy                                                                                       
#0 0.121 2025/03/26 13:23:24 [INFO] Temporary folder: /tmp/buildenv_2025-03-26-1323.986400998                                                                       
#0 0.121 2025/03/26 13:23:24 [INFO] Writing main module: /tmp/buildenv_2025-03-26-1323.986400998/main.go                                                            
#0 0.121 package main                                                                                                                                               
#0 0.121 
#0 0.121 import (
#0 0.121        caddycmd "github.com/caddyserver/caddy/v2/cmd"
#0 0.121 
#0 0.121        // plug in Caddy modules here
#0 0.121        _ "github.com/caddyserver/caddy/v2/modules/standard"
#0 0.121        _ "github.com/caddy-dns/cloudflare"
#0 0.121        _ "github.com/greenpau/caddy-security"
#0 0.121 )
#0 0.121 
#0 0.121 func main() {
#0 0.121        caddycmd.Main()
#0 0.121 }
#0 0.122 2025/03/26 13:23:24 [INFO] Initializing Go module
#0 0.124 2025/03/26 13:23:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod init caddy 
#0 0.235 go: creating new go.mod: module caddy
#0 0.247 go: to add module requirements and sums:
#0 0.247        go mod tidy
#0 0.253 2025/03/26 13:23:24 [INFO] Pinning versions
#0 0.253 2025/03/26 13:23:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -v github.com/caddyserver/caddy/[email protected] 
#0 0.716 go: downloading github.com/caddyserver/caddy/v2 v2.9.1
#0 1.521 go: downloading github.com/caddyserver/certmagic v0.21.6
#0 1.521 go: downloading github.com/cespare/xxhash/v2 v2.3.0
#0 1.522 go: downloading github.com/google/uuid v1.6.0
#0 1.524 go: downloading github.com/prometheus/client_golang v1.19.1
#0 1.631 go: downloading github.com/cespare/xxhash v1.1.0
#0 1.674 go: downloading github.com/quic-go/quic-go v0.48.2
#0 1.807 go: downloading go.uber.org/zap v1.27.0
#0 1.809 go: downloading go.uber.org/zap/exp v0.3.0
#0 2.055 go: downloading golang.org/x/sys v0.28.0
#0 2.299 go: downloading golang.org/x/term v0.27.0
#0 2.299 go: downloading golang.org/x/time v0.7.0
#0 2.599 go: downloading github.com/caddyserver/zerossl v0.1.3
#0 2.600 go: downloading github.com/klauspost/cpuid/v2 v2.2.9
#0 2.616 go: downloading github.com/libdns/libdns v0.2.2
#0 2.692 go: downloading github.com/mholt/acmez/v3 v3.0.0
#0 2.726 go: downloading github.com/miekg/dns v1.1.62
#0 2.841 go: downloading github.com/zeebo/blake3 v0.2.4
#0 2.843 go: downloading golang.org/x/crypto v0.31.0
#0 2.955 go: downloading golang.org/x/net v0.33.0
#0 3.042 go: downloading github.com/beorn7/perks v1.0.1
#0 3.135 go: downloading github.com/prometheus/client_model v0.5.0
#0 3.211 go: downloading github.com/prometheus/common v0.48.0
#0 3.238 go: downloading github.com/prometheus/procfs v0.12.0
#0 3.426 go: downloading google.golang.org/protobuf v1.35.1
#0 3.573 go: downloading go.uber.org/multierr v1.11.0
#0 3.585 go: downloading github.com/francoispqt/gojay v1.2.13
#0 3.682 go: downloading github.com/onsi/ginkgo/v2 v2.13.2
#0 3.816 go: downloading github.com/quic-go/qpack v0.5.1
#0 4.022 go: downloading go.uber.org/mock v0.4.0
#0 4.024 go: downloading golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
#0 4.372 go: downloading golang.org/x/tools v0.22.0
#0 4.570 go: downloading golang.org/x/text v0.21.0
#0 4.614 go: downloading golang.org/x/mod v0.18.0
#0 5.994 go: downloading github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572
#0 6.024 go: downloading golang.org/x/sync v0.10.0
#0 6.108 go: downloading github.com/google/pprof v0.0.0-20231212022811-ec68065c825e
#0 10.34 go: added github.com/beorn7/perks v1.0.1
#0 10.34 go: added github.com/caddyserver/caddy/v2 v2.9.1
#0 10.34 go: added github.com/caddyserver/certmagic v0.21.6
#0 10.34 go: added github.com/caddyserver/zerossl v0.1.3
#0 10.34 go: added github.com/cespare/xxhash/v2 v2.3.0
#0 10.34 go: added github.com/francoispqt/gojay v1.2.13
#0 10.34 go: added github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572
#0 10.34 go: added github.com/google/pprof v0.0.0-20231212022811-ec68065c825e
#0 10.34 go: added github.com/google/uuid v1.6.0
#0 10.34 go: added github.com/klauspost/cpuid/v2 v2.2.9
#0 10.34 go: added github.com/libdns/libdns v0.2.2
#0 10.34 go: added github.com/mholt/acmez/v3 v3.0.0
#0 10.34 go: added github.com/miekg/dns v1.1.62
#0 10.34 go: added github.com/onsi/ginkgo/v2 v2.13.2
#0 10.34 go: added github.com/prometheus/client_golang v1.19.1
#0 10.34 go: added github.com/prometheus/client_model v0.5.0
#0 10.34 go: added github.com/prometheus/common v0.48.0
#0 10.34 go: added github.com/prometheus/procfs v0.12.0
#0 10.34 go: added github.com/quic-go/qpack v0.5.1
#0 10.34 go: added github.com/quic-go/quic-go v0.48.2
#0 10.34 go: added github.com/zeebo/blake3 v0.2.4
#0 10.34 go: added go.uber.org/mock v0.4.0
#0 10.34 go: added go.uber.org/multierr v1.11.0
#0 10.34 go: added go.uber.org/zap v1.27.0
#0 10.34 go: added go.uber.org/zap/exp v0.3.0
#0 10.34 go: added golang.org/x/crypto v0.31.0
#0 10.34 go: added golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
#0 10.34 go: added golang.org/x/mod v0.18.0
#0 10.34 go: added golang.org/x/net v0.33.0
#0 10.34 go: added golang.org/x/sync v0.10.0
#0 10.34 go: added golang.org/x/sys v0.28.0
#0 10.34 go: added golang.org/x/term v0.27.0
#0 10.34 go: added golang.org/x/text v0.21.0
#0 10.34 go: added golang.org/x/time v0.7.0
#0 10.34 go: added golang.org/x/tools v0.22.0
#0 10.34 go: added google.golang.org/protobuf v1.35.1
#0 10.35 2025/03/26 13:23:34 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -v github.com/caddy-dns/cloudflare github.com/caddyserver/caddy/[email protected] 
#0 11.11 go: downloading github.com/caddy-dns/cloudflare v0.0.0-20250228175314-1fb64108d4de
#0 11.18 go: accepting indirect upgrade from github.com/libdns/[email protected] to v0.2.3
#0 11.21 go: downloading github.com/libdns/cloudflare v0.1.3
#0 11.26 go: downloading github.com/libdns/libdns v0.2.3
#0 11.52 go: added github.com/caddy-dns/cloudflare v0.0.0-20250228175314-1fb64108d4de
#0 11.52 go: added github.com/libdns/cloudflare v0.1.3
#0 11.52 go: upgraded github.com/libdns/libdns v0.2.2 => v0.2.3
#0 11.53 2025/03/26 13:23:35 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -v github.com/greenpau/caddy-security github.com/caddyserver/caddy/[email protected] 
#0 12.25 go: downloading github.com/greenpau/caddy-security v1.1.31
#0 12.36 go: github.com/greenpau/[email protected] requires go >= 1.24 (running go 1.23.7; GOTOOLCHAIN=local)
#0 12.37 2025/03/26 13:23:36 [FATAL] exit status 1
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:2
--------------------
   1 |     FROM caddy:builder AS builder
   2 | >>> RUN xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/greenpau/caddy-security
   3 |     FROM caddy:latest
   4 |     RUN addgroup -S caddy && adduser -S -G caddy caddy
--------------------
ERROR: failed to solve: process "/bin/sh -c xcaddy build --with github.com/caddy-dns/cloudflare --with github.com/greenpau/caddy-security" did not complete successfully: exit code: 1

Expected behavior

I'm expecting a succesfull docker build since i'm not doing anything special, and building it without caddy-security does work.

Additional context

Tried running it on portainer (linux/amd64 and on my mac/arm64)

martijndierckx avatar Mar 26 '25 13:03 martijndierckx

Seeing the same issue. Had to roll back to caddy-security 1.1.29 to successfully build an image. I suspect we will need to wait for caddy v2.9.1 to be prod before using the latest version of caddy-security.

samcro1967 avatar Mar 26 '25 14:03 samcro1967

@martijndierckx , @samcro1967 , please see for the solution https://github.com/caddyserver/xcaddy/issues/232#issuecomment-2752206831

greenpau avatar Mar 26 '25 16:03 greenpau

This fix worked initially for me, but started failing again yesterday with a different error. Seems like there is now a mismatch between versions of CertMagic and libdns. Appears there is already an issue open to address this that can be found here: https://github.com/caddyserver/certmagic/issues/340

#8 28.83 2025/04/09 13:42:31 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath -tags nobadger,nomysql,nopgx 
#8 41.76 # github.com/caddyserver/certmagic
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:386:9: invalid composite literal type libdns.Record
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:445:17: zrec.record.Type undefined (type libdns.Record has no field or method Type)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:449:45: zrec.record.Name undefined (type libdns.Record has no field or method Name)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:462:42: zrec.record.Type undefined (type libdns.Record has no field or method Type)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:463:45: zrec.record.Value undefined (type libdns.Record has no field or method Value)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:467:79: zrec.record.Value undefined (type libdns.Record has no field or method Value)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:469:116: zrec.record.Name undefined (type libdns.Record has no field or method Name)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:507:39: zrec.record.ID undefined (type libdns.Record has no field or method ID)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:508:41: zrec.record.Name undefined (type libdns.Record has no field or method Name)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: zrec.record.Type undefined (type libdns.Record has no field or method Type)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: too many errors
#8 47.45 2025/04/09 13:42:50 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2025-04-09-1342.418128730
#8 47.45 2025/04/09 13:42:50 [FATAL] exit status 1
#8 ERROR: process "/bin/sh -c GOTOOLCHAIN=go1.24.1 xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2     --with github.com/greenpau/caddy-security@latest     --with github.com/greenpau/caddy-trace     --with github.com/porech/caddy-maxmind-geolocation     --with github.com/caddy-dns/cloudflare     --with github.com/oschwald/maxminddb-golang     --with github.com/sjtug/caddy2-filter" did not complete successfully: exit code: 1
------
 > [builder 2/2] RUN GOTOOLCHAIN=go1.24.1 xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2     --with github.com/greenpau/caddy-security@latest     --with github.com/greenpau/caddy-trace     --with github.com/porech/caddy-maxmind-geolocation     --with github.com/caddy-dns/cloudflare     --with github.com/oschwald/maxminddb-golang     --with github.com/sjtug/caddy2-filter:
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:462:42: zrec.record.Type undefined (type libdns.Record has no field or method Type)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:463:45: zrec.record.Value undefined (type libdns.Record has no field or method Value)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:467:79: zrec.record.Value undefined (type libdns.Record has no field or method Value)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:469:116: zrec.record.Name undefined (type libdns.Record has no field or method Name)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:507:39: zrec.record.ID undefined (type libdns.Record has no field or method ID)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:508:41: zrec.record.Name undefined (type libdns.Record has no field or method Name)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: zrec.record.Type undefined (type libdns.Record has no field or method Type)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: too many errors
47.45 2025/04/09 13:42:50 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2025-04-09-1342.418128730
47.45 2025/04/09 13:42:50 [FATAL] exit status 1
------
Dockerfile:5
--------------------
   4 |     
   5 | >>> RUN GOTOOLCHAIN=go1.24.1 xcaddy build \
   6 | >>>     --with github.com/lucaslorentz/caddy-docker-proxy/v2 \
   7 | >>>     --with github.com/greenpau/caddy-security@latest \
   8 | >>>     --with github.com/greenpau/caddy-trace \
   9 | >>>     --with github.com/porech/caddy-maxmind-geolocation \
  10 | >>>     --with github.com/caddy-dns/cloudflare \
  11 | >>>     --with github.com/oschwald/maxminddb-golang \
  12 | >>>     --with github.com/sjtug/caddy2-filter
  13 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c GOTOOLCHAIN=go1.24.1 xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2     --with github.com/greenpau/caddy-security@latest     --with github.com/greenpau/caddy-trace     --with github.com/porech/caddy-maxmind-geolocation     --with github.com/caddy-dns/cloudflare     --with github.com/oschwald/maxminddb-golang     --with github.com/sjtug/caddy2-filter" did not complete successfully: exit code: 1

samcro1967 avatar Apr 09 '25 13:04 samcro1967

This fix worked initially for me, but started failing again yesterday with a different error. Seems like there is now a mismatch between versions of CertMagic and libdns. Appears there is already an issue open to address this that can be found here: caddyserver/certmagic#340

#8 28.83 2025/04/09 13:42:31 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath -tags nobadger,nomysql,nopgx 
#8 41.76 # github.com/caddyserver/certmagic
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:386:9: invalid composite literal type libdns.Record
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:445:17: zrec.record.Type undefined (type libdns.Record has no field or method Type)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:449:45: zrec.record.Name undefined (type libdns.Record has no field or method Name)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:462:42: zrec.record.Type undefined (type libdns.Record has no field or method Type)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:463:45: zrec.record.Value undefined (type libdns.Record has no field or method Value)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:467:79: zrec.record.Value undefined (type libdns.Record has no field or method Value)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:469:116: zrec.record.Name undefined (type libdns.Record has no field or method Name)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:507:39: zrec.record.ID undefined (type libdns.Record has no field or method ID)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:508:41: zrec.record.Name undefined (type libdns.Record has no field or method Name)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: zrec.record.Type undefined (type libdns.Record has no field or method Type)
#8 41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: too many errors
#8 47.45 2025/04/09 13:42:50 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2025-04-09-1342.418128730
#8 47.45 2025/04/09 13:42:50 [FATAL] exit status 1
#8 ERROR: process "/bin/sh -c GOTOOLCHAIN=go1.24.1 xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2     --with github.com/greenpau/caddy-security@latest     --with github.com/greenpau/caddy-trace     --with github.com/porech/caddy-maxmind-geolocation     --with github.com/caddy-dns/cloudflare     --with github.com/oschwald/maxminddb-golang     --with github.com/sjtug/caddy2-filter" did not complete successfully: exit code: 1
------
 > [builder 2/2] RUN GOTOOLCHAIN=go1.24.1 xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2     --with github.com/greenpau/caddy-security@latest     --with github.com/greenpau/caddy-trace     --with github.com/porech/caddy-maxmind-geolocation     --with github.com/caddy-dns/cloudflare     --with github.com/oschwald/maxminddb-golang     --with github.com/sjtug/caddy2-filter:
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:462:42: zrec.record.Type undefined (type libdns.Record has no field or method Type)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:463:45: zrec.record.Value undefined (type libdns.Record has no field or method Value)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:467:79: zrec.record.Value undefined (type libdns.Record has no field or method Value)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:469:116: zrec.record.Name undefined (type libdns.Record has no field or method Name)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:507:39: zrec.record.ID undefined (type libdns.Record has no field or method ID)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:508:41: zrec.record.Name undefined (type libdns.Record has no field or method Name)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: zrec.record.Type undefined (type libdns.Record has no field or method Type)
41.76 /go/pkg/mod/github.com/caddyserver/[email protected]/solvers.go:509:41: too many errors
47.45 2025/04/09 13:42:50 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2025-04-09-1342.418128730
47.45 2025/04/09 13:42:50 [FATAL] exit status 1
------
Dockerfile:5
--------------------
   4 |     
   5 | >>> RUN GOTOOLCHAIN=go1.24.1 xcaddy build \
   6 | >>>     --with github.com/lucaslorentz/caddy-docker-proxy/v2 \
   7 | >>>     --with github.com/greenpau/caddy-security@latest \
   8 | >>>     --with github.com/greenpau/caddy-trace \
   9 | >>>     --with github.com/porech/caddy-maxmind-geolocation \
  10 | >>>     --with github.com/caddy-dns/cloudflare \
  11 | >>>     --with github.com/oschwald/maxminddb-golang \
  12 | >>>     --with github.com/sjtug/caddy2-filter
  13 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c GOTOOLCHAIN=go1.24.1 xcaddy build     --with github.com/lucaslorentz/caddy-docker-proxy/v2     --with github.com/greenpau/caddy-security@latest     --with github.com/greenpau/caddy-trace     --with github.com/porech/caddy-maxmind-geolocation     --with github.com/caddy-dns/cloudflare     --with github.com/oschwald/maxminddb-golang     --with github.com/sjtug/caddy2-filter" did not complete successfully: exit code: 1

Had the same issue, just use the previous version of github.com/caddy-dns/cloudflare for now:

--with github.com/caddy-dns/cloudflare@188b4850c0f2f5565a6310810c936ea960e2210f

denisgabriel5 avatar Apr 09 '25 13:04 denisgabriel5

That is working again for now. Seems like the caddy platform is getting caught up in dependency hell.

samcro1967 avatar Apr 09 '25 21:04 samcro1967

That is working again for now. Seems like the caddy platform is getting caught up in dependency hell.

Works due to my fix or because they actually solved the dependency issue?

denisgabriel5 avatar Apr 09 '25 21:04 denisgabriel5

Works due to your fix.

samcro1967 avatar Apr 09 '25 21:04 samcro1967

after the new release everything builds wonderfully and also with the updated toolchain for go. Unfortunately I can no longer create api keys because of this error in the gui Error: Profile API found non-compliant API key value

brummbaerrocket avatar Apr 15 '25 10:04 brummbaerrocket

This is what I'm currently doing to build using xcaddy in a dockerfile, it's what I did to work around the issue:

# Stage 1: Build Caddy with Go 1.24.0
FROM golang:1.24.0-alpine AS builder

# Set Caddy version
ARG CADDY_VERSION=2.9.1

# Install necessary build tools
RUN apk add --no-cache git gcc musl-dev

# Install xcaddy
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

# Build Caddy with the specified plugins
RUN xcaddy build v${CADDY_VERSION} \
    --output /usr/local/bin/caddy \
    --with github.com/caddy-dns/porkbun \
    --with github.com/greenpau/caddy-security \
    --with github.com/mholt/caddy-l4 \
    --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/aksdb/caddy-cgi/v2

# Stage 2: Create a lightweight runtime image
FROM alpine:latest

# Install runtime dependencies
RUN apk add --no-cache ca-certificates curl

# Copy Caddy binary from the builder stage
COPY --from=builder /usr/local/bin/caddy /usr/bin/caddy

# Run Caddy
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

SinisterSpatula avatar May 04 '25 21:05 SinisterSpatula