Unable to build the release version of Caddy (with the Cloudflare plugin)

1. Caddy version (caddy version):

root@caddy:~ # caddy version
v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=

2. How I run Caddy:

I use Caddyfile rather than JSON.

a. System environment:

TrueNAS 12.0-U3 (a FreeBSD derivative)

b. Command:

service caddy start

c. Service/unit/compose file:

n/a

d. My complete Caddyfile or JSON config:

n/a

3. The problem I’m having:

I’m currently running the latest beta release of Caddy including the Cloudflare module. For reference purposes, I’m trying to build a second instance of Caddy based on the official release (currently 2.3.0). I’m not having any success building this.

4. Error messages and/or full log output:

I don’t seem to be able to build anything but the latest beta. Version info appears to be ignored.

root@caddy:/tmp # xcaddy build v2.3.0 --output /tmp --with github.com/caddy-dns/cloudflare
2021/05/02 00:54:23 [INFO] Temporary folder: /tmp/buildenv_2021-05-02-0054.495923719
2021/05/02 00:54:23 [INFO] Writing main module: /tmp/buildenv_2021-05-02-0054.495923719/main.go
2021/05/02 00:54:23 [INFO] Initializing Go module
2021/05/02 00:54:23 [INFO] exec (timeout=10s): /usr/local/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/05/02 00:54:23 [INFO] Pinning versions
2021/05/02 00:54:23 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddyserver/caddy/v2@v2.3.0
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/05/02 00:54:30 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddy-dns/cloudflare
go get: added github.com/caddy-dns/cloudflare v0.0.0-20210401224357-964e47d3890e
go get: upgraded github.com/caddyserver/caddy/v2 v2.3.0 => v2.4.0-beta.2
2021/05/02 00:54:31 [INFO] Build environment ready
2021/05/02 00:54:31 [INFO] Building Caddy
2021/05/02 00:54:31 [INFO] exec (timeout=0s): /usr/local/bin/go mod tidy
2021/05/02 00:54:32 [INFO] exec (timeout=0s): /usr/local/bin/go build -o /tmp -ldflags -w -s -trimpath
2021/05/02 00:54:35 [INFO] Build complete: /tmp
2021/05/02 00:54:35 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-05-02-0054.495923719
root@caddy:/tmp # /tmp/caddy version
v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=

5. What I already tried:

I’ve also tried specifying the build version using the CADDY_VERSION environmental variable, but this doesn’t appear to work either.

root@caddy:/tmp # setenv CADDY_VERSION "v2.3.0"
root@caddy:/tmp # echo $CADDY_VERSION
v2.3.0
root@caddy:/tmp # xcaddy build --output /tmp --with github.com/caddy-dns/cloudflare
2021/05/02 01:51:37 [INFO] Temporary folder: /tmp/buildenv_2021-05-02-0151.000047087
2021/05/02 01:51:37 [INFO] Writing main module: /tmp/buildenv_2021-05-02-0151.000047087/main.go
2021/05/02 01:51:37 [INFO] Initializing Go module
2021/05/02 01:51:37 [INFO] exec (timeout=10s): /usr/local/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/05/02 01:51:37 [INFO] Pinning versions
2021/05/02 01:51:37 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddyserver/caddy/v2@v2.3.0
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/05/02 01:51:43 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddy-dns/cloudflare
go get: added github.com/caddy-dns/cloudflare v0.0.0-20210401224357-964e47d3890e
go get: upgraded github.com/caddyserver/caddy/v2 v2.3.0 => v2.4.0-beta.2
2021/05/02 01:51:46 [INFO] Build environment ready
2021/05/02 01:51:46 [INFO] Building Caddy
2021/05/02 01:51:46 [INFO] exec (timeout=0s): /usr/local/bin/go mod tidy
2021/05/02 01:51:46 [INFO] exec (timeout=0s): /usr/local/bin/go build -o /tmp -ldflags -w -s -trimpath
2021/05/02 01:51:47 [INFO] Build complete: /tmp
2021/05/02 01:51:47 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-05-02-0151.000047087
root@caddy:/tmp # /tmp/caddy version
v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=

6. Links to relevant resources:

  1. xcaddy - Custom Caddy Builder

Known issue. The latest version of the Cloudflare plugin requires the latest beta. It’s just a downside of how Go dependency management works. See this issue (includes a workaround) but I recommend to just use the latest beta anyways.

1 Like