Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README example fails to build against matching Caddy version #34

Closed
jonahgeorge opened this issue Apr 10, 2024 · 9 comments
Closed

README example fails to build against matching Caddy version #34

jonahgeorge opened this issue Apr 10, 2024 · 9 comments

Comments

@jonahgeorge
Copy link

jonahgeorge commented Apr 10, 2024

It appears that trying to compile this module into Caddy using the matching Caddy docker image is not working:

FROM caddy:2.7.6-builder AS builder
ENV XCADDY_SETCAP 0
RUN xcaddy build v2.7.6 --with github.com/tailscale/caddy-tailscale

FROM caddy:2.7.6
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile /etc/caddy/Caddyfile

Results in the following build error:

go: github.com/tailscale/caddy-tailscale@v0.0.0-20240324222951-7b5a952a5b8b requires go >= 1.22.0 (running go 1.21.9; GOTOOLCHAIN=local)

Relates to:


It appears that this commit 0f105e89fbe2222c690b94b5b0b2a8150fa2540f introduces the Go toolchain bump. I was able to get past this by pinning to a specific commit prior to the Go toolchain bump:

FROM caddy:2.7.6-builder AS builder
ENV XCADDY_SETCAP 0
RUN xcaddy build v2.7.6 --with github.com/tailscale/caddy-tailscale@e041e1578ce91ef7d278dcec7e62e5af8362d79e

FROM caddy:2.7.6
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY Caddyfile /etc/caddy/Caddyfile
@willnorris
Copy link
Member

It looks like the toolchain bump got removed in 7b5a952. But caddy-tailscale still requires go1.22, so it won't build on caddy:2.7.6-builder since that only has go1.21. There's not really much we can do about that.

It does look like the caddy 2.8 builder has updated to go1.22, so you could try that now even though 2.8 is still in beta.

@mholt
Copy link
Contributor

mholt commented May 16, 2024

/cc @mohammed90 @francislavoie I thought by downgrading we wouldn't be blocking out plugins but rather allowing the others to build 🤔

@mohammed90
Copy link

mohammed90 commented May 16, 2024

/cc @mohammed90 @francislavoie I thought by downgrading we wouldn't be blocking out plugins but rather allowing the others to build 🤔

Our builder image of 2.7.6 ships with go1.21. The requirement for go1.22 isn't from Caddy; it's caddy-tailscale, so the builder image fails to build it because the plugin requires higher version than installed (in the container).

This isn't on Caddy to act on

@mholt
Copy link
Contributor

mholt commented May 16, 2024

Ah, a Docker thing. Got it.

@francislavoie
Copy link

francislavoie commented May 16, 2024

Well

go 1.22.0
was it necessary to bump to 1.22 in this plugin's go.mod? Does the actual tailscale dependency itself require 1.22?

Anyway yeah, using the 2.8.0-beta.2 builder image is perfectly fine too.

@willnorris
Copy link
Member

Yes, Tailscale pretty much always requires the latest go. We often run betas internally, but don't update our public dependency until stable releases. But we're pretty quick to update.

@willnorris
Copy link
Member

We are now building against Caddy 2.8, so moving to the 2.8 builder image should solve this for you, since it has go1.22.

That said, it's important to note that you will likely run into this again at some point in the future. Tailscale is generally pretty aggressive about updating to the latest stable go release as soon as it releases, which means that the caddy-tailscale plugin will not be far behind. Caddy is generally more conservative when it comes to bumping minimum go versions, so you might need to consider other ways of building your images.

@willnorris
Copy link
Member

This Dockerfile seemed to work well for me, building xcaddy from source rather than using the caddy-builder image:

FROM golang:1 AS builder
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
ENV XCADDY_SETCAP 0
RUN xcaddy build v2.8.4 --with github.com/tailscale/caddy-tailscale@main --output /usr/bin/caddy

FROM caddy:2.8
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY examples/simple.caddyfile /etc/caddy/Caddyfile

(For my personal site, I generally prefer the chainguard images rather than alpine and use my own main package, but any of these will work)

@willnorris
Copy link
Member

I don't think there is anything more to do here, so I'm going to close this. However, feel free to continue discussing if here is actually something else we should do. One possible option would be to provide a ready-to-go Dockerfile (maybe the above one?) as requested in #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants