2020-03-21 20:31:29 +00:00
Custom Caddy Builder
====================
This package and associated CLI tool make it easy to perform custom builds of the [Caddy Web Server ](https://github.com/caddyserver/caddy ).
Supports Caddy 2 and up.
2020-03-25 06:01:44 +00:00
⚠️ Still in early development. Works; but no guarantees and prone to changes at this point. Stay updated and please submit feedback!
2020-03-21 20:31:29 +00:00
## Requirements
- Go installed
- Go modules enabled
## Library usage
```go
2020-04-04 16:56:37 +01:00
builder := xcaddy.Builder{
CaddyVersion: "v2.0.0-rc.1",
Plugins: []xcaddy.Dependency{
{
{
ModulePath: "github.com/caddyserver/nginx-adapter",
Version: "bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4",
},
}
}
2020-03-21 20:31:29 +00:00
}
2020-04-04 16:56:37 +01:00
err := builder.Build("./caddy")
2020-03-21 20:31:29 +00:00
```
Versions can be anything compatible with `go get` .
## CLI usage
2020-03-25 06:01:44 +00:00
The CLI can be used both to make custom builds of Caddy, but also as a replacement for `go run` while developing Caddy plugins.
2020-04-02 16:05:25 +01:00
### Download
```
go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
```
2020-03-25 06:01:44 +00:00
### For custom builds
2020-03-21 20:31:29 +00:00
Syntax:
```
2020-03-25 06:01:44 +00:00
xcaddy build < version >
[--output < file > ]
[--with < module [ @ version ] > ...]
2020-03-21 20:31:29 +00:00
```
Where:
2020-03-25 06:01:44 +00:00
- `--version` is the core Caddy version to build (required, for now).
2020-03-21 20:31:29 +00:00
- `--output` changes the output file.
2020-03-25 06:01:44 +00:00
- `--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:
```bash
2020-04-04 16:56:37 +01:00
$ xcaddy build v2.0.0-rc.1 \
--with github.com/caddyserver/nginx-adapter@bdbb6db7ff9ad6ceb0dcd93f89e396f6365aa5d4
2020-03-25 06:01:44 +00:00
```
### 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.
2020-03-21 20:31:29 +00:00
For example:
```bash
2020-03-25 06:01:44 +00:00
$ xcaddy list-modules
$ xcaddy run --config caddy.json
2020-03-21 20:31:29 +00:00
```
---
© 2020 Matthew Holt