Open thepatrick opened 5 years ago
Run docker pull abiosoft/caddy:builder
and try again.
It's either still or again broken. In my case with a different, but similar error, related to import / module paths.
The image is the newest, see:
$ docker pull abiosoft/caddy:builder
builder: Pulling from abiosoft/caddy
Digest: sha256:81531392fb405b064c95f13cfb59e8340e6380fe0febc73d340ade7b43101b83
Status: Image is up to date for abiosoft/caddy:builder
Then I want to build an image with the proxy
plugin:
$ docker build --build-arg plugins=proxy -t local/caddy github.com/abiosoft/caddy-docker.git
[...]
github.com/miekg/dns
github.com/go-acme/lego/challenge/dns01
github.com/go-acme/lego/challenge/resolver
github.com/go-acme/lego/lego
github.com/mholt/certmagic
github.com/caddyserver/caddy
package caddy:
proxy.go:2:10: invalid import path: ""
finished stage: customising plugins and telemetry ✓
starting stage: building caddy
go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
go: downloading github.com/gorilla/websocket v1.4.0
[...]
go: extracting gopkg.in/natefinch/lumberjack.v2 v2.0.0
can't load package: package caddy:
proxy.go:2:10: invalid import path: ""
error at 'building caddy'
The command '/bin/sh -c VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=${enable_telemetry} /bin/sh /usr/bin/builder.sh' returned a non-zero code: 1
Ah my bad I think. proxy
is an invalid plugin name if I'm not mistaken, as it's already part of Caddy.
Building with an empty plugin list plugins=""
works fine.
Maybe the error message can be improved. For exmple when building with plugins=foo
, there should be an early check if foo
is a valid plugin at all and then the build should exit with an appropriate error and a clear message to the user. foo.go:2:10: invalid import path: ""
instead looks like some error in a Go file (well, it probably is and the file is generated during build time, but this makes it hard to understand what the real issue is).
@philippgille yeah, the message can be better. You can open a separate issue to address that.
I'm having the same issue but with the default plugin list.
I added some debug to builder.sh, and I believe the error is now caused by caddyplug not using the Caddy version as requested by the image.
Here's the interesting part of the log:
starting stage: generating plugins
+ tr , ' '
+ echo git,cors,realip,expires,cache,cloudflare
+ get_package git
+ true
+ '[' -f /dnsproviders/git/git.go ]
+ GO111MODULE=off GOOS=linux GOARCH=amd64 caddyplug package git
fetching missing dependencies: caddy, dnsproviders, hook.pluginloader
[...]
github.com/caddyserver/caddy
Cloning into '/root/lib/caddy/gopath/src/github.com/caddyserver/dnsproviders'...
github.com/abiosoft/caddyplug (download)
github.com/abiosoft/caddyplug/internal
github.com/abiosoft/caddyplug
# github.com/abiosoft/caddyplug
/root/lib/caddy/gopath/src/github.com/abiosoft/caddyplug/caddyplug.go:18:2: undefined: caddy.RegisterEventHook
/root/lib/caddy/gopath/src/github.com/abiosoft/caddyplug/caddyplug.go:21:10: undefined: caddy.EventHook
/root/lib/caddy/gopath/src/github.com/abiosoft/caddyplug/caddyplug.go:21:39: undefined: caddy.EventName
/root/lib/caddy/gopath/src/github.com/abiosoft/caddyplug/caddyplug.go:23:7: undefined: caddy.StartupEvent
exit status 2
+ import_package=
+ '[' -z ]
+ echo 'Could not determine package for plugin git'
+ return 1
+ end_stage
+ '[' 1 -ne 0 ]
+ echo error at ''"'"'generating' 'plugins'"'"
error at 'generating plugins'
+ exit 1
My intuition is the undefined
errors are due to caddyplug now using Caddy 2 instead of the one specified in $VERSION
.
I'm willing to spend some time fixing this, but need your guidance. Do you think I'm right about the cause? How should I go about and fix this?
docker build
is failing for me today with the error:go: github.com/mholt/caddy@v1.0.1: parsing go.mod: unexpected module path "github.com/caddyserver/caddy"
Full logs below: