Repository navigation
Replace vfsgen with embed for static web assets - #10220
Conversation
|
Thanks, looks good (although I would be happy if sometime in the future the compression step in the Makefile could be removed). @roidelapluie can you answer the |
|
I have released v0.1.0 |
| common-build: promu | ||
| @bash -c "trap 'echo \">> restoring assets\"; scripts/compress_assets.sh -d;' EXIT; \ | ||
| echo '>> compressing assets'; \ | ||
| scripts/compress_assets.sh; \ |
There was a problem hiding this comment.
Why not having this in "assets" ?
There was a problem hiding this comment.
Apologies if I misunderstand...
This compresses the assets that are specific to prometheus and are located in this repo. For, say alertmanager the assets are different and in a different location. I'm not sure how that could be handled from the common repo.
There was a problem hiding this comment.
I mean, put this under "make assets" not "make build"
There was a problem hiding this comment.
Ahh I see.
The main idea is that I can clean up (i.e. decompress) the assets in case the build fails. If we put the compression into the asset target, we need an extra decompress target. And it also becomes more awkward to run this automatically in case the build fails.
I'd even argue this is the right place conceptually. The assets are ready to go as is, the compression step is really an optimization to keep the binary size a bit smaller. Building prometheus without the compression step still yields a correct binary, its just ~10 MB larger.
There was a problem hiding this comment.
I still think it should be part of make assets, and not build. Why would we need a decompress? Do we need decompress if we have make clean?
There was a problem hiding this comment.
I also think that using trap is an advanced move, I am not sure we should do this.
731a297 to
a984439
Compare
Signed-off-by: Jan Fajerski <[email protected]>
a984439 to
df34176
Compare
|
|
||
| .PHONY: assets | ||
| assets: ui-install ui-build | ||
| @echo ">> writing assets" |
There was a problem hiding this comment.
This is where I would write it
This requires go 1.16. Signed-off-by: Jan Fajerski <[email protected]>
Signed-off-by: Jan Fajerski <[email protected]>
This commit add compression before (and decompression after) prometheus is build. This ensures that gzipped assets are embeded in the prometheus binary, if the builtinassets build tag is passed. If the build tag is not passed this step is still executed but has no effect. All this is executed in a subshell so that we can run the decompress step even if the build step fails, but retain the exit code of promu. This cleanup could also cover interrupts, but I left that out for now. Signed-off-by: Jan Fajerski <[email protected]>
What do you think of this version? |
df34176 to
6a11233
Compare
|
This has been sitting here in an approved state for a while now, so I'll merge it. Thanks again! 👍 |
|
Thanks @jan--f ! |
* remove vfsgen usages Signed-off-by: Jan Fajerski <[email protected]> * web: use embed package for static assets This requires go 1.16. Signed-off-by: Jan Fajerski <[email protected]> * circleci: drop go generate in web/ui Signed-off-by: Jan Fajerski <[email protected]> * Makefile: compress web assets before build This commit add compression before (and decompression after) prometheus is build. This ensures that gzipped assets are embeded in the prometheus binary, if the builtinassets build tag is passed. If the build tag is not passed this step is still executed but has no effect. All this is executed in a subshell so that we can run the decompress step even if the build step fails, but retain the exit code of promu. This cleanup could also cover interrupts, but I left that out for now. Signed-off-by: Jan Fajerski <[email protected]>
With prometheus/prometheus#10220 and prometheus/prometheus#10467 prometheus no longer needs a dedicated asset generation step. This change made in into prometheus v2.35.0. Signed-off-by: Jan Fajerski <[email protected]>
This file seem to be a remaining of prometheus#10220 Signed-off-by: Arunprasad Rajkumar <[email protected]>
This file seem to be a remaining of #10220 Signed-off-by: Arunprasad Rajkumar <[email protected]>
This file seem to be a remaining of prometheus#10220 Signed-off-by: Arunprasad Rajkumar <[email protected]>
This replicates work done in the prometheus repo in prometheus/prometheus#10220 plus a few follow up PRs. Asset compression is handled via https://github.com/prometheus/common/tree/main/assets Signed-off-by: Jan Fajerski <[email protected]>
Another attempt at #9719.
Is a
v0.1.0release ofcommon/assetspreferable over usingv0.0.0-20220106224503-00591a3ea9c0?