xcaddy/README.md

104 lines
2.2 KiB
Markdown
Raw Normal View History

2020-04-08 01:56:30 +01:00
`xcaddy` - Custom Caddy Builder
===============================
2020-03-21 20:31:29 +00:00
2020-04-08 01:56:30 +01:00
This command line tool and associated Go package makes it easy to make custom builds of the [Caddy Web Server](https://github.com/caddyserver/caddy).
It is used heavily by Caddy plugin developers as well as anyone who wishes to make custom `caddy` binaries (with or without plugins).
2020-03-21 20:31:29 +00:00
Supports Caddy 2 and up.
2020-04-08 01:56:30 +01:00
⚠️ Still in development.
Stay updated, be aware of changes, and please submit feedback! Thanks!
2020-03-21 20:31:29 +00:00
## Requirements
- Go installed
- Go modules enabled
2020-04-08 01:56:30 +01:00
## Command usage
2020-03-21 20:31:29 +00:00
2020-04-08 01:56:30 +01:00
The `xcaddy` command has two primary uses:
2020-03-21 20:31:29 +00:00
2020-04-08 01:56:30 +01:00
- Compile custom `caddy` binaries
- A replacement for `go run` while developing Caddy plugins
2020-04-08 01:56:30 +01:00
Install the `xcaddy` command with:
2020-04-08 01:56:30 +01:00
```bash
$ go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
```
2020-04-08 01:56:30 +01:00
### Custom builds
2020-03-21 20:31:29 +00:00
Syntax:
```
2020-04-08 01:56:30 +01:00
$ xcaddy build <caddy_version>
[--output <file>]
[--with <module[@version]>...]
2020-03-21 20:31:29 +00:00
```
2020-04-08 01:56:30 +01:00
- `<caddy_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-04-08 01:56:30 +01:00
- `--with` can be used multiple times to add plugins by specifying the Go module name and optionally its version, similar to `go get`.
For example:
```bash
2020-04-04 16:56:37 +01:00
$ xcaddy build v2.0.0-rc.1 \
2020-04-08 01:56:30 +01:00
--with github.com/caddyserver/ntlm-transport@v0.1.0
```
### For plugin development
2020-04-08 01:56:30 +01:00
If you run `xcaddy` from within the folder of the Caddy plugin you're working on without the `build` subcommand described above, it will build Caddy with your current module and run it, as if you manually plugged it in and ran `go run`.
The binary will be built and run from the current directory, then cleaned up.
2020-04-08 01:56:30 +01:00
The current working directory must be inside an initialized Go module.
Syntax:
```
2020-04-08 01:56:30 +01:00
$ xcaddy <args...>
```
- `<args...>` are passed through to the `caddy` command.
2020-03-21 20:31:29 +00:00
For example:
```bash
$ xcaddy list-modules
2020-04-08 01:56:30 +01:00
$ xcaddy run
$ xcaddy run --config caddy.json
2020-03-21 20:31:29 +00:00
```
2020-04-08 01:56:30 +01:00
## Library usage
```go
builder := xcaddy.Builder{
CaddyVersion: "v2.0.0-rc.1",
Plugins: []xcaddy.Dependency{
{
ModulePath: "github.com/caddyserver/ntlm-transport",
Version: "v0.1.0",
},
},
}
err := builder.Build("./caddy")
```
Versions can be anything compatible with `go get`.
2020-03-21 20:31:29 +00:00
---
&copy; 2020 Matthew Holt