Closed justusbunsi closed 2 years ago
I don't think that's true, actually.
Upgrade your version of xcaddy to v0.3.0 and it should be fine.
Edit: Confirmed, I built with xcaddy build --with github.com/baldinof/caddy-supervisor
and it worked fine. (Note the b
in baldinof
needs to be lowercase to match the module name)
Hi. That's odd. I've used following Dockerfile spec that reproduces the issue:
FROM golang:1.17.2-bullseye
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@v0.3.0
RUN xcaddy build --with github.com/baldinof/caddy-supervisor@latest
I also tried with github.com/caddyserver/xcaddy/cmd/xcaddy@latest
just to be sure it doesn't work.
Both attempts result in following error
#0 35.47 caddy imports
#0 35.47 github.com/baldinof/caddy-supervisor imports
#0 35.47 github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile imports
#0 35.47 github.com/caddyserver/caddy/v2/modules/caddyhttp imports
#0 35.47 github.com/google/cel-go/parser imports
#0 35.47 github.com/antlr/antlr4/runtime/Go/antlr loaded from github.com/antlr/antlr4/runtime/Go/antlr@v0.0.0-20220626175859-9abda183db8e,
#0 35.47 but go 1.16 would fail to locate it:
#0 35.47 ambiguous import: found package github.com/antlr/antlr4/runtime/Go/antlr in multiple modules:
#0 35.47 github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f (/go/pkg/mod/github.com/antlr/antlr4@v0.0.0-20200503195918-621b933c7a7f/runtime/Go/antlr)
#0 35.47 github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220626175859-9abda183db8e (/go/pkg/mod/github.com/antlr/antlr4/runtime/!go/antlr@v0.0.0-20220626175859-9abda183db8e)
#0 35.47
#0 35.47 To proceed despite packages unresolved in go 1.16:
#0 35.47 go mod tidy -e
#0 35.47 If reproducibility with go 1.16 is not needed:
#0 35.47 go mod tidy -compat=1.17
#0 35.47 For other options, see:
#0 35.47 https://golang.org/doc/modules/pruning
Use Go 1.18
Or use the caddy:builder
image which is set up for building Caddy plugins with xcaddy
. See https://hub.docker.com/_/caddy
Here's what it looks like for me:
$ ./xcaddy build --with github.com/baldinof/caddy-supervisor
2022/07/13 10:26:46 [INFO] Temporary folder: /tmp/buildenv_2022-07-13-1026.1710224096
2022/07/13 10:26:46 [INFO] Writing main module: /tmp/buildenv_2022-07-13-1026.1710224096/main.go
package main
import (
caddycmd "github.com/caddyserver/caddy/v2/cmd"
// plug in Caddy modules here
_ "github.com/caddyserver/caddy/v2/modules/standard"
_ "github.com/baldinof/caddy-supervisor"
)
func main() {
caddycmd.Main()
}
2022/07/13 10:26:46 [INFO] Initializing Go module
2022/07/13 10:26:46 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
go mod tidy
2022/07/13 10:26:46 [INFO] Pinning versions
2022/07/13 10:26:46 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go: added github.com/beorn7/perks v1.0.1
go: added github.com/caddyserver/caddy/v2 v2.5.2
go: added github.com/caddyserver/certmagic v0.16.1
go: added github.com/cespare/xxhash/v2 v2.1.2
go: added github.com/cheekybits/genny v1.0.0
go: added github.com/fsnotify/fsnotify v1.5.1
go: added github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
go: added github.com/golang/protobuf v1.5.2
go: added github.com/google/uuid v1.3.0
go: added github.com/klauspost/cpuid/v2 v2.0.13
go: added github.com/libdns/libdns v0.2.1
go: added github.com/lucas-clemente/quic-go v0.28.0
go: added github.com/marten-seemann/qpack v0.2.1
go: added github.com/marten-seemann/qtls-go1-16 v0.1.5
go: added github.com/marten-seemann/qtls-go1-17 v0.1.2
go: added github.com/marten-seemann/qtls-go1-18 v0.1.2
go: added github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1
go: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go: added github.com/mholt/acmez v1.0.2
go: added github.com/miekg/dns v1.1.46
go: added github.com/nxadm/tail v1.4.8
go: added github.com/onsi/ginkgo v1.16.4
go: added github.com/prometheus/client_golang v1.12.1
go: added github.com/prometheus/client_model v0.2.0
go: added github.com/prometheus/common v0.32.1
go: added github.com/prometheus/procfs v0.7.3
go: added go.uber.org/atomic v1.9.0
go: added go.uber.org/multierr v1.6.0
go: added go.uber.org/zap v1.21.0
go: added golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2
go: added golang.org/x/mod v0.4.2
go: added golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
go: added golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
go: added golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
go: added golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b
go: added golang.org/x/tools v0.1.7
go: added golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: added google.golang.org/protobuf v1.28.0
go: added gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
2022/07/13 10:26:46 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/baldinof/caddy-supervisor github.com/caddyserver/caddy/v2
go: downloading github.com/baldinof/caddy-supervisor v0.6.0
go: downloading github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220626175859-9abda183db8e
go: downloading github.com/antlr/antlr4 v4.10.1+incompatible
go: upgraded github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed => v0.0.0-20220626175859-9abda183db8e
go: added github.com/baldinof/caddy-supervisor v0.6.0
2022/07/13 10:26:53 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v
2022/07/13 10:26:54 [INFO] Build environment ready
2022/07/13 10:26:54 [INFO] Building Caddy
2022/07/13 10:26:54 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
2022/07/13 10:26:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o ./caddy -ldflags -w -s -trimpath
2022/07/13 10:27:26 [INFO] Build complete: ./caddy
2022/07/13 10:27:26 [INFO] Cleaning up temporary folder: /tmp/buildenv_2022-07-13-1026.1710224096
So many ways to have a successful Caddy build. 😃 Thanks for your fast response. I can confirm that using Go 1.18 works. I didn't knew there is a caddy:builder
image tag. I'm switching to that image.
Closing the PR as it's not necessary. Thanks again.
Thank you @francislavoie I would not have been as efficient :D
And thanks @justusbunsi for the report / fix attempt :)
With Caddy release v2.5.2, this plugin does not build anymore when using
xcaddy build --with github.com/Baldinof/caddy-supervisor
. Looks like https://github.com/caddyserver/caddy/commit/10f85558ead15e119f8e9abd81c8ad55eb865f8b causes it due to the change of packagegithub.com/antlr/antlr4
.Its a breaking change as it requires Caddy version v2.5.2 and higher.