Repository navigation
Conversation
This requires go 1.16. Signed-off-by: Jan Fajerski <[email protected]>
|
That's a nice improvement and cleanup. Now that go 1.17.1 is out, it is also reasonable to use go1.16 features. However you have raised a few interesting points, I will try to investigate as well. 10MB seems a lot. |
|
I had a look at the respective intermediate compiled packages. Using I can also look into compressing the assets before embedding, though that may have performance implications. |
Signed-off-by: Jan Fajerski <[email protected]>
Signed-off-by: Jan Fajerski <[email protected]>
This adds a PoC gzip layer to the embed fs in order to reduce the binary
size. This requires an additional asset compression step before building prometheus:
find web/ui/templates web/ui/static -type f -exec gzip {} \;
After the build completed run the following to reset the repository:
find web/ui/static web/ui/templates -name "*gz" -exec rm {} \; && g restore web/ui/static web/ui/templates
Signed-off-by: Jan Fajerski <[email protected]>
6a1275c to
73dc69e
Compare
|
@roidelapluie I added an additional layer that unzips content on the fly. So if the Unfortunately this currently requires an additional step before building (see below), so it doesn't improve on the existing solution in that respect. It does however bring down the binary size to something closer that a current I do think this still offers improvements:
In order to try this run this before building the binary: and to cleanup run |
Note that without this step, the build should still succeed and produce a functioning binary, it will however contain the uncompressed static assets and thus be roughly 10MB bigger than needed. |
|
Closing in favor of #9719 |
$title describes the PR pretty well. The
embedpackage was added in go 1.16 and offers a nice way to embed static files into a binary.I marked this RFC because
embedcurrently offers no exclude directive, i.e. this initial version of the PR adds the resources excluded here to the binary. The resulting binary is about 10.6 MB larger than a v2.30.0 build (111522587 B instead of 100382142 B) on my machine. I'm not sure though if that is purely caused by the additional assets (iiuc that is currently only bootstrap.js and bootstrap.css, which certainly don't sum up to 10 MB).Furthermore the current version will include any file that is added to the
staticandtemplatessubdirectory.Possible solutions:
//go:embeddirectives, that include only the things that are needed instead of relying on naive globbing.One of the latter two is probably desirable, I'm just not sure which is easier to maintain. I also might be missing other options.