Skip to content

Commit

Permalink
README: add docs for docker builds
Browse files Browse the repository at this point in the history
Updates tailscale/tailscale#8905

Signed-off-by: Will Norris <[email protected]>
  • Loading branch information
willnorris committed Nov 5, 2024
1 parent c357e48 commit f21c01b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,43 @@ In those cases, this plugin may be helpful.
[automatic certificates]: https://caddyserver.com/docs/automatic-https#activation
[authenticate Tailscale users]: https://caddyserver.com/docs/caddyfile/directives/forward_auth#tailscale

## Installation
## Building

Use [xcaddy](https://github.com/caddyserver/xcaddy) to build Caddy with the Tailscale plugin included.

```sh
xcaddy build v2.8.4 --with github.com/tailscale/caddy-tailscale
```

Alternatively, you can build the included `cmd/caddy` package:
Alternatively, you can build the included `cmd/caddy` package, or create your own similar package:

```sh
go build ./cmd/caddy
```

### Docker Builds

Caddy provides [builder docker images] (e.g. `caddy:2.8-builder`) that have xcaddy pre-installed.
These can be used to build caddy-tailscale in a docker container,
but may result in issues with the Go version used for the build due to project release cycles.

The caddy builder images are built with the specific Go version that was used for that Caddy version.
If a new version of Go has been released, that will not be reflected until a future Caddy release.
Tailscale, and by extension the caddy-tailscale plugin, adopts new Go versions much more quickly,
which may result in a caddy-tailscale version requiring a more recent version of Go than is in the caddy builder image.

This can be addressed in two ways:

1. don't use the caddy builder images directly, but install xcaddy in a newer Go build image
as [discussed in this comment].
2. unset the `GOTOOLCHAIN` environment variable so that Go is able to upgrade itself:
```sh
docker run -e GOTOOLCHAIN= -i -t --rm caddy:2.7-builder sh -c "xcaddy build --with github.com/tailscale/caddy-tailscale@0f105e89fbe2222c690b94b5b0b2a8150fa2540f"
```

[builder docker images]: https://hub.docker.com/_/caddy
[discussed in this comment]: https://github.com/tailscale/caddy-tailscale/issues/34#issuecomment-2145764893

### Running examples

Multiple example configurations are provided in the [examples directory].
Expand Down

0 comments on commit f21c01b

Please sign in to comment.