Repository navigation
Replace vfsgen with embed for static web assets - #9719
Conversation
Signed-off-by: Jan Fajerski <[email protected]>
This requires go 1.16. Signed-off-by: Jan Fajerski <[email protected]>
Signed-off-by: Jan Fajerski <[email protected]>
| @echo ">> compressing assets" | ||
| @scripts/compress_assets.sh | ||
| @echo ">> building binaries" | ||
| GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES) |
There was a problem hiding this comment.
If anything goes wrong in this step, the assets stay compressed... could we decompress them not in-place, but to some alternative temporary place, and then embed them from there?
There was a problem hiding this comment.
embed will only accept directives that are below or at the same level as the including file (directive may not start the / or include ..) so anything like that would have to happen in web/ui/. I think this requirement will mess with builds not built with builtinassets.
I figured the assets staying compressed is the least bad solution as git would easily be able to revert that.
There was a problem hiding this comment.
@juliusv How about this solution: the three steps are executed in a single sub-shell, i.e. if the build has an error, the decompress step is run regardless.
There was a problem hiding this comment.
I added the cleanup step as a trap on EXIT. This should now always decompress the assets whether the build fails or succeeds, while returning the correct exit code.
@juliusv I'd much appreciate if you could take another look.
5ae0221 to
44d5bd7
Compare
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]>
Signed-off-by: Jan Fajerski <[email protected]>
44d5bd7 to
6e6257f
Compare
|
Thanks 👍 I think it's good enough for now. I'm still not super happy with introducing that much new "shell noise" into the Makefile in the long term... but I guess the native Go embedding will never support compression of assets? |
|
Thanks, I certainly agree about the shell noise, I tried to keep it to a minimum. |
|
Thanks, that's an interesting read! I hope they add it, as the tradeoffs they talk about would definitely be better with compression in our case :) |
This reverts commit ddaddc2.
|
I have reverted this pull request for two reasons that we will have to address:
I will make those changes once common is released. thanks! |
|
Thanks and apologies for the churn. |
This replaces #9380.
Note that this still contains a go mod replace for
prometheus/common. I'll remove this once prometheus/common#343 has landed.