Build Caddy with plugins
Go to file
2020-04-04 09:56:41 -06:00
cmd/xcaddy Improve exported API, update docs 2020-04-04 09:56:41 -06:00
.gitignore Add gitignore 2020-03-21 16:26:52 -06:00
builder.go Improve exported API, update docs 2020-04-04 09:56:41 -06:00
environment.go Improve exported API, update docs 2020-04-04 09:56:41 -06:00
go.mod Update name to xcaddy 2020-04-02 08:35:27 -06:00
go.sum Initial commit 2020-03-21 14:31:29 -06:00
LICENSE Initial commit 2020-03-21 14:31:29 -06:00
README.md Improve exported API, update docs 2020-04-04 09:56:41 -06:00

Custom Caddy Builder

This package and associated CLI tool make it easy to perform custom builds of the Caddy Web Server.

Supports Caddy 2 and up.

⚠️ Still in early development. Works; but no guarantees and prone to changes at this point. Stay updated and please submit feedback!

Requirements

  • Go installed
  • Go modules enabled

Library usage

builder := xcaddy.Builder{
	CaddyVersion: "v2.0.0-rc.1",
	Plugins: []xcaddy.Dependency{
		{
			{
				ModulePath: "github.com/caddyserver/nginx-adapter",
				Version:    "bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4",
			},
		}
	}
}
err := builder.Build("./caddy")

Versions can be anything compatible with go get.

CLI usage

The CLI can be used both to make custom builds of Caddy, but also as a replacement for go run while developing Caddy plugins.

Download

go get -u github.com/caddyserver/xcaddy/cmd/xcaddy

For custom builds

Syntax:

xcaddy build <version>
	[--output <file>]
	[--with <module[@version]>...]

Where:

  • --version is the core Caddy version to build (required, for now).
  • --output changes the output file.
  • --with can be used multiple times to add plugins by specifying the module name and optionally its version, in a way similar to go get.

For example:

$ xcaddy build v2.0.0-rc.1 \
	--with github.com/caddyserver/nginx-adapter@bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4

For plugin development

If you run xcaddy from within the folder of the Caddy plugin you're working on without the build subcommand, it will build Caddy with your current module and run it, similar to if you manually plugged it in and ran go run.

The binary will be built, run from the current directory, then cleaned up.

Syntax:

xcaddy <args...>

Where:

  • <args...> are passed through to the caddy command.

For example:

$ xcaddy list-modules
$ xcaddy run --config caddy.json

© 2020 Matthew Holt