So… How do you automatically build “CoreDNS” as a plugin in Caddy?
Right now I manually edit
caddy/caddymain/run.go and add my servertype. I would be nice to have some sort of automatic way of doing this, like
caddyext did for plugins in the go’old days.
Preferable something that works with
go get. Should I write a
go generate thing that does this automatically…? Should not be too hard come to think of it…
We’ll probably be building a replacement for
caddyext in the future, although the details remain to be decided. All it takes is adding a line to run.go.
Anyway, the build server on caddyserver.com does this for you, so most people won’t need it. And developers already have their hands in the code anyway. So I’m still unsure at how much this tool will need to do, really.
Hmm, call me old fashion, but I still like
make to build me a binary that I can use. Also something like this will be needed for my travis tests (in the future). Having a build server is nice, but easy building from source is a big plus, esp for getting new devs involved.
A rather not play with sed/awk, so I think I will go ahead and use
go/ast to add this one line, just so that I’m able to
go build my project.
Also this would be a regression from the current CoreDNS, something I have a hard time accepting.
Double hmmm. I’m not sure where this
go gen script should live… For now I will add some detailed notes in the README, but it would be nice of there is some for automation here.
I do agree actually, just have to get around to it. Do what you think is best for CoreDNS and hopefully we can still have it as a plugin to Caddy.
yes, plugin is still happening
Think the concrete problem here is: how do I build a coredns/caddy binary with travis, just to see if the build succeeds.
Ah. Good question. … I don’t have an answer for you right now… hmm, I will have to think on this. Definitely can see why that would be needed.
Should be pretty simple from the Caddy site though…? Well apart from adding the line that includes coredns.
It’s mostly a go get and building caddy and then renaming to coredns…?
Then I can just download caddy, compile coredns and run my tests (which are all contained in my repo)
Not sure I follow… you can do a git pull, yes, then add that line and build – should do the trick. Not sure how you want to add that import line though.
Sorry, I was in a rush and it was a bit terse. But yes, just what you said.
Shall I whip up an
go gen thingy that adds that line? I think you should then be able to build with
go build -tags=coredns and let it add that line. (I think)
For your repo or mine? If this is for your CI tests, that sounds like a fine solution for now anyway.
That should live in Caddy’s repo
Oh. Why’s that, when it’s for your CI tests?
Not that I don’t want to help… just feels weird to treat one plugin specially and build in this codegen.
Hmm, maybe not. I’m not sure how I can find caddy’s source. But maybe I can do it from my side (has my preference as well btw)
So this https://github.com/miekg/test-throwaway-plugin/blob/master/plugin.go adds the CoreDNS import to
run.go (and it’s idempotent).
So, next, how would my build work? Dev. downloads the CoreDNS repo, does a
go get -u or whatever. This should pull in Caddy. (We can now assume caddy lives in
Anyway this script needs to be triggered, so when you you run
go build in the coredns’s dir it will execute. This can be done as a
go generate thing. OK done.
But now you need to build caddy yourself. This involves going to the caddymain’s dir and running
./build.bash. Then I would like to copy the
caddy binary to my dir and rename it to
I could make
go generate execute these steps well, meaning the whole thing can still be build with
This has been implemented and works
I was wondering though: should I disable the http plugin when I build CoreDNS?
If you’re distributing CoreDNS as its own binary from its own website, then yes, that is probably a good idea. But from the Caddy download page, for instance, there’s no reason that HTTP and DNS both can’t be compiled in. The user chooses at launch time which server type the Caddyfile is for.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.