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

Allow swagger to be excluded from build #114

Closed
eternal-flame-AD opened this issue Jan 19, 2019 · 5 comments
Closed

Allow swagger to be excluded from build #114

eternal-flame-AD opened this issue Jan 19, 2019 · 5 comments
Labels
a:feature New feature or request in:server
Milestone

Comments

@eternal-flame-AD
Copy link
Member

I discovered that swagger UI is heavy in the final binary. I tried building without it and got the following results:

Swagger + WebUI Swagger Only WebUI Only No User Interface
39M 33M (-17.9%) 28M (-28.2%) 21M(-46.1%)

I think most people would not use the Swagger UI functionality, and a nearly 30% decrease in binary size is worth doing from my point of view, this is substantial if it is running on a highly limited environment(like an OpenWrt router, etc.).

Changes Proposed

  1. Add two build tags(nowebui noswagger) to exclude Swagger UI and WebUI from builds.
  2. Permit CORS to /swagger and redirect /docs/*any to the swagger UI hosted on gotify.net page with our custom URL to /swagger.

Example: eternal-flame-AD@47a37cd

@jmattheis
Copy link
Member

Good Catch.

I don't really like having multiple binaries with different features. I'd say we only have one optimized binary.

Currently a full swagger ui is shipped with gotify/server, we could only ship a html file with external dependencies like this: https://github.com/gotify/server/blob/0a32e86bcac4bc5471887dc0580a3b9442a5ebe1/docs/ui.go
This reduces the size of the swagger ui to 1.63KB.

Futhermore images could be optimized by https://imgbot.net/ see #115 (optimized less than I expected (: )

And lastly we can use the linker flags -w and -s which both strip debugging information.

@eternal-flame-AD
Copy link
Member Author

If you don't want to make any compromise on features, upx can compress the binary by around 50%

@jmattheis
Copy link
Member

upx seems pretty amazing, it shrinked my binary to 6MB.

@eternal-flame-AD
Copy link
Member Author

That is impressive. Maybe we can consider adding upx into release workflow.

@jmattheis
Copy link
Member

For adding upx I've created #118. The rest should be fixed with #116.

@jmattheis jmattheis added a:feature New feature or request in:server labels Jan 21, 2019
@jmattheis jmattheis added this to the v1.3.0 milestone Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature New feature or request in:server
Development

No branches or pull requests

2 participants