address feedback

This commit is contained in:
Mohammed Al Sahaf 2024-02-03 17:47:14 +03:00 committed by Francis Lavoie
parent 41fceffc71
commit e8cf230117
No known key found for this signature in database
GPG key ID: 0F66EE1687682239

View file

@ -4,10 +4,10 @@ title: "Build from source"
# Build from source
There are 2 ways to build Caddy, as opposed to installation of pre-built executable:
- Build from Git repo
- Build using `xcaddy`
- Build custom Docker image
There are 2 ways to build Caddy if you need to customize Caddy:
- [Git](#git): Build from Git repo
- [`xcaddy`](#xcaddy): Build using `xcaddy`
- [Docker](#docker) Build custom Docker image
Requirements:
@ -15,7 +15,7 @@ Requirements:
The [last section](#package-support-files-for-custom-builds-for-debianubunturaspbian) contains instructions for users who installed Caddy using the APT command on Debian-derivative system yet need the custom build executable for their operations.
## Build from Git repo
## Git
Requirements:
@ -49,7 +49,7 @@ Or similarly for Linux ARMv6 when you're not on Linux or on ARMv6:
<pre><code class="cmd bash">GOOS=linux GOARCH=arm GOARM=6 go build</code></pre>
## Build using `xcaddy`
## xcaddy
The [`xcaddy` command](https://github.com/caddyserver/xcaddy) is the easiest way to build Caddy with version information and/or plugins.
@ -76,23 +76,9 @@ Cross-platform compilation with `xcaddy` works the same as with the `go` command
<pre><code class="cmd bash">GOOS=darwin xcaddy build</code></pre>
## Build Custom Docker Image
## Docker
Most users deploying production sites will not want to rely on mounting files into a container, but will instead base their own images on `caddy`:
```Dockerfile
# note: never use the :latest tag in a production site
FROM caddy:<version>
COPY Caddyfile /etc/caddy/Caddyfile
COPY site /srv
```
#### Adding custom Caddy modules
Caddy is extendable through the use of "modules". See https://caddyserver.com/docs/extending-caddy for full details. You can find a list of available modules on [the Caddy website's download page](https://caddyserver.com/download).
You can use the `:builder` image as a short-cut to building a new Caddy binary:
You can use the `:builder` image as a short-cut to building a new Caddy binary with custom modules:
```Dockerfile
FROM caddy:<version>-builder AS builder
@ -108,9 +94,7 @@ COPY --from=builder /usr/bin/caddy /usr/bin/caddy
Note the second `FROM` instruction - this produces a much smaller image by simply overlaying the newly-built binary on top of the regular `caddy` image.
The [`xcaddy`](https://caddyserver.com/docs/build#xcaddy) tool is used to [build a new Caddy entrypoint](https://github.com/caddyserver/caddy/blob/4217217badf220d7d2c25f43f955fdc8454f2c64/cmd/caddy/main.go#L15..L25), with the provided modules. You can specify just a module name, or a name with a version (separated by `@`). You can also specify a specific version (can be a version tag or commit hash) of Caddy to build from. Read more about [`xcaddy` usage](https://github.com/caddyserver/xcaddy#command-usage).
Note that the "standard" Caddy modules ([`github.com/caddyserver/caddy/master/modules/standard`](https://github.com/caddyserver/caddy/tree/master/modules/standard)) are always included.
The builder uses `xcaddy` to Caddy with the provided modules, similar to the process outlined in the [`xcaddy`](#xcaddy) section.
## Package support files for custom builds for Debian/Ubuntu/Raspbian