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

add Dockerfile and GitHub action for building image #63

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

willnorris
Copy link
Member

@willnorris willnorris commented Jun 7, 2024

This largely mirrors the default Caddy image. (I generally use chainguard images to limit dependencies, but stuck with alpine, since that's what Caddy uses for it's main images)

The GitHub Action is duplicated from what we have for tailscale/golink. I don't really know a lot of best practices for Dockerfiles, so am really looking for any input. I have this using the simple.caddyfile as the default config, which is easy to override.

Updates #14

@willnorris willnorris requested a review from irbekrm June 7, 2024 05:25
@willnorris willnorris force-pushed the will/dockerfile branch 2 times, most recently from 5e15b1a to 6ce2c3e Compare June 7, 2024 05:46
@willnorris
Copy link
Member Author

wow, 16 minutes to build the image for two platforms :(

Copy link
Contributor

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense in general, I've left two suggestions.

I think ko would be faster than Docker build, but it seems like it is not possible to expose ports using ko ko-build/ko#472

labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

# Sign the Docker image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Dockerfile Outdated
Comment on lines 5 to 6
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest && \
xcaddy build v${CADDY_VERSION} --with github.com/tailscale/caddy-tailscale@main --output /usr/bin/caddy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest && \
xcaddy build v${CADDY_VERSION} --with github.com/tailscale/caddy-tailscale@main --output /usr/bin/caddy
RUN go run github.com/caddyserver/xcaddy/cmd/xcaddy@latest build v${CADDY_VERSION} \
--with github.com/tailscale/caddy-tailscale@main --output /usr/bin/caddy

maybe makes it a little faster?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm wondering if we can use the tailscale-caddy repo checkout available to this action rather than refer to github.com/tailscale/caddy-tailscale@main? The checkout should presumably bet the one corresponding to the push event

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be surprised if go run was actually any faster, but certainly doesn't hurt so let's give it a try.

And oops, totally forgot to instruct it to use the local source for building. I'll add that.

@willnorris
Copy link
Member Author

I think ko would be faster than Docker build, but it seems like it is not possible to expose ports using ko ko-build/ko#472

EXPOSE is really just to document what ports are exposed mapped, right? But it's not really necessary to be able to map ports?

It also looks like ko really wants a simple main package that it can build. That would mean bypassing xcaddy entirely for our builds and having our own simple cmd. Which is totally fine, that's actually what I do for my personal website. I'll actually do that first as a separate PR.

This largely mirrors the default Caddy image.

Updates #14

Signed-off-by: Will Norris <will@tailscale.com>
@willnorris willnorris marked this pull request as draft June 7, 2024 18:41
@irbekrm
Copy link
Contributor

irbekrm commented Jun 7, 2024

It also looks like ko really wants a simple main package that it can build. That would mean bypassing xcaddy entirely for our builds and having our own simple cmd.

We also have our own container builder that is a stripped down version of ko and that allows to include multiple binaries https://github.com/tailscale/mkctr. But I think we don't have an option to include static files with that

@irbekrm
Copy link
Contributor

irbekrm commented Jun 7, 2024

EXPOSE is really just to document what ports are exposed mapped, right? But it's not really necessary to be able to map ports?

That is my understanding, yes. Also, we don't expose ports for any of the other images we build (for example the k8s-operator that runs a server and listens on 443 and the tsrecorder)

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

Successfully merging this pull request may close these issues.

2 participants