Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: remove server subcommand from slim binaries #5747

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

Merged
merged 4 commits into from
Jan 17, 2023
Merged

Conversation

deansheather
Copy link
Member

@deansheather deansheather commented Jan 17, 2023

  • Add slim tag if this is a slim build
  • Add IsSlim() and IsAGPL() to buildinfo, and add those details to coder version
  • Adds server_slim.go (in both AGPL and enterprise CLI) which only builds with slim tag
  • Move serveHandler from server.go to agent.go

This doesn't fully remove the server code from slim binaries, as the packages are still imported, but it disables them.

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Looking good, had some small suggestions but pre-approving.

@@ -73,6 +75,16 @@ func IsDev() bool {
return strings.HasPrefix(Version(), develPrefix)
}

// IsSlim returns true if this is a slim build.
func IsSlim() bool {
return strings.Contains(slim, "t")
Copy link
Member

@mafredri mafredri Jan 17, 2023

Choose a reason for hiding this comment

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

Could we set this via build tag so that it's present when doing go build as well? (I.e. we don't need to inject it via ldflags.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Like by using go build -tags slim?

Copy link
Member

Choose a reason for hiding this comment

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

Yup

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but we won't be able to detect agpl this way since we don't use a flag for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done for slim, AGPL still uses ldflags. I've added a comment to build_go.sh why we don't provide an agpl build flag

"github.com/spf13/viper"

"github.com/coder/coder/cli/deployment"
"github.com/coder/coder/coderd"
Copy link
Member

Choose a reason for hiding this comment

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

Importing coderd here is unfortunate. I think we could reduce binary size if we didn't but I might be wrong. I think we can avoid it if we change enterprise slim too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly also root.go uses this function so the signature needs to match on both. I think this could be done as a second improvement, but I want to get this in so we can unblock the community PR #5738

Copy link
Member

Choose a reason for hiding this comment

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

Ah, didn't think of that. Yes makes sense 👍🏻.

@deansheather deansheather requested a review from mafredri January 17, 2023 16:11
@deansheather deansheather enabled auto-merge (squash) January 17, 2023 16:51
@deansheather deansheather merged commit 7f5dcc3 into main Jan 17, 2023
@deansheather deansheather deleted the dean/slim branch January 17, 2023 16:58
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants