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

ui: replace go-bindata with embed #3816

Closed
wants to merge 5 commits into from
Closed

Conversation

longngn
Copy link
Contributor

@longngn longngn commented Feb 20, 2021

Fixes #3782

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

  • Replace go-bindata with embed

Verification

  • I open web UI of thanos query and thanos tools bucket web and saw no error

@longngn
Copy link
Contributor Author

longngn commented Feb 20, 2021

Why with go-bindata, we ignored (.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)?

@longngn
Copy link
Contributor Author

longngn commented Feb 20, 2021

One check blocked by prometheus/golang-builder#109

@GiedriusS
Copy link
Member

GiedriusS commented Feb 21, 2021

Why with go-bindata, we ignored (.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)?

Source maps increase the binary's size by a lot so that would hurt more than add benefits, and I don't remember about bootstrap. IIRC it's because we use the minified versions in the final build:

pkg/ui/templates/_base.html:        <script src="{{ pathPrefix }}/static/vendor/bootstrap-4.1.3/js/bootstrap.min.js?v={{ buildVersion }}"></script>
pkg/ui/templates/_base.html:        <link type="text/css" rel="stylesheet" href="{{ pathPrefix }}/static/vendor/bootstrap-4.1.3/css/bootstrap.min.css?v={{ buildVersion }}">

Copy link
Member

@kakkoyun kakkoyun 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!!! Thanks @longngn

However could you please extract to go upgrade part into another PR? And follow https://github.com/thanos-io/thanos/blob/master/docs/contributing/how-to-change-go-version.md

It makes life easier for us to track down the issues.

Base automatically changed from master to main February 26, 2021 16:31
@longngn longngn mentioned this pull request Apr 9, 2021
2 tasks
@kakkoyun
Copy link
Member

kakkoyun commented Apr 9, 2021

@longngn Let's rebase and move forward with this as well.

@kakkoyun
Copy link
Member

Hey @longngn 👋 We're going to cut a release candidate soon, is there any chance for you to push this to the finish line?

@longngn
Copy link
Contributor Author

longngn commented Apr 21, 2021

Hey @longngn 👋 We're going to cut a release candidate soon, is there any chance for you to push this to the finish line?

@kakkoyun I've rebased with the main branch. AFAIK there's no way to exclude certain pattern with go embed, so the resulting binary might be heavier. On my Mac the binary size is 67MB.

@kakkoyun
Copy link
Member

@longngn Thanks for the heads up.
I think we need to discuss if we really want this?
cc @bwplotka @GiedriusS @onprem

@bwplotka
Copy link
Member

Is this something we can tell the Go goembed community? Create some issue?

I don't think 67MB is considered big, but for safety I would release Thanos 0.20 without it. WDYT?

@brancz
Copy link
Member

brancz commented Apr 21, 2021

We still have a build process that produces the build artifacts of the react app, no? What's the problem with deleting everything except the resulting artifact for release binaries?

@onprem
Copy link
Member

onprem commented Apr 21, 2021

I think we are excluding the source-maps from the build artifacts currently which contributes to the size reduction. Since we are deleting these source-maps anyways, I vote for not even generating them (this can be done setting env variable GENERATE_SOURCEMAP=false).

@onprem
Copy link
Member

onprem commented Apr 21, 2021

I just did three builds locally, thanos-bindata is current main branch, thanos-embed-sourcemap is the build from this branch which contains the sourcemaps, and the third thanos-embed binary is with a patch on top of this branch to not generate sourcemaps (modified scripts/build-react-app.sh to have PUBLIC_URL=. GENERATE_SOURCEMAP=false yarn build).

-rwxr-xr-x  1 prem prem  56M Apr 21 14:51 thanos-bindata
-rwxr-xr-x  1 prem prem  61M Apr 21 15:02 thanos-embed
-rwxr-xr-x  1 prem prem  69M Apr 21 14:58 thanos-embed-sourcemap

There's about 5M of difference between bindata (without sourcemaps) and go-embed without sourcemaps which sounds acceptable to me.

@kakkoyun
Copy link
Member

@longngn Could you please rebase?

longngn added 5 commits April 21, 2021 17:52
Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
@longngn
Copy link
Contributor Author

longngn commented Apr 21, 2021

@longngn Could you please rebase?

Done.
IMO we could delete the sourcemap and unnecessary files in release pre-build step, and keep them in dev build for easier debugging.

@stale
Copy link

stale bot commented Jun 20, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Jun 20, 2021
@stale stale bot closed this Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace go-bindata with a better alternative
6 participants