diff --git a/README.md b/README.md index e03d31d36..08196dee7 100644 --- a/README.md +++ b/README.md @@ -75,17 +75,54 @@ Caddy binaries have no dependencies and are available for every platform. Get Ca ## Build -To build from source you need **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.12 or newer). Follow these instruction for fast building: +To build from source you need **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.12 or newer). -- Set the transitional environment variable `GO111MODULE` to `on` -- Get the source with `go get github.com/mholt/caddy/caddy` and then run `go get github.com/caddyserver/builds` -- Now `cd $GOPATH/src/github.com/mholt/caddy/caddy` and run `go run build.go` +**To build Caddy without plugins:** -Then make sure the `caddy` binary is in your PATH. + +1. Set the transitional environment variable for Go modules: `export GO111MODULE=on` + +2. Run `go get github.com/mholt/caddy/caddy@1.0.0-beta2` -To build for other platforms, use build.go with the `--goos` and `--goarch` flags. +Caddy will be installed to your `$GOPATH/bin` folder. -When building from source, telemetry is enabled by default. You can disable it by changing `enableTelemetry` in run.go before compiling, or use the `-disabled-metrics` flag at runtime to disable only certain metrics. +With these instructions, the binary will not have embedded version information (see [golang/go#29228](https://github.com/golang/go/issues/29228)), but it is fine for a quick start. + +**To build Caddy with plugins (and with version information):** + +There is no need to modify the Caddy code to build it with plugins. We will create a simple Go module with our own `main()` that you can use to make custom Caddy builds. + + +1. Set the transitional environment variable for Go modules: `export GO111MODULE=on` +2. Create a new folder anywhere, and put this Go file into it, then import the plugins you want to include: +```go +package main + +import ( + "github.com/mholt/caddy/caddy/caddymain" + + // plug in plugins here, for example: + // _ "import/path/here" +) + +func main() { + // optional: disable telemetry + // caddymain.EnableTelemetry = false + caddymain.Run() +} +``` +3. `go mod init mycaddy` (the name doesn't really matter). +4. `go install` will then create your binary at `$GOPATH/bin`, or `go build` will put it in the current directory. + +**To install Caddy's source code for development:** + + +1. Set the transitional environment variable for Go modules: `export GO111MODULE=on` +2. Run `git clone https://github.com/mholt/caddy.git` in any folder (doesn't have to be in GOPATH). + +You can make changes to the source code in this repo, since it is a Go module. + +When building from source, telemetry is enabled by default. You can disable it by changing `caddymain.EnableTelemetry = false` in run.go, or use the `-disabled-metrics` flag at runtime to disable only certain metrics. ## Quick Start