feat(frontend): do not embed frontend assets anymore#63946
Conversation
|
Caution License checking failed, please read: how to deal with third parties licensing. |
6f41b74 to
0a41dee
Compare
e0193db to
3afddfb
Compare
keegancsmith
left a comment
There was a problem hiding this comment.
It's a little unclear how this all fits together. I guess I just wanna check the follow properties are true:
- in development we reload web.manifest.json if it changes. Otherwise its only read once.
- in prod you can't trick the location of the asset dir. I think that is the case and http.FileSystem won't allow access outside of the passed in dir.
What I'm a little unclear is why we allow customizing the value of the asset dir outside of dev. It seems like when constructing docker images we can just always hardcode the location of the asset dir?
There was a problem hiding this comment.
Should we not just assert this always is set and that it is an absolute path?
There was a problem hiding this comment.
I have added the absolute path test, but didn't change it to check that it is always set, since there are places where it isn't set and set via other means like https://sourcegraph.com/github.com/sourcegraph/sourcegraph@bc4acd1fbd278b8bb414241f286420dc8c69c047/-/blob/cmd/frontend/shared/service.go?L26-28
eseliger
left a comment
There was a problem hiding this comment.
someone makes a client/web change = frontend needs to be rebuilt
someone makes a frontend change = assets need to be rebuilt
I do understand the first one, but how does a cmd/frontend change cause assets needing to be rebuilt? 🤔
Left a few comments here about ramdisk before and non-portability of this, which are both things I could be convinced to find ok, but initially they feel a bit of a loss to me.
There was a problem hiding this comment.
I assume the http.Dir always reads from disk? Right now it is a ram-disk. Not sure if that has performance implications or scalability implications since the disk that holds rootFS in kubernetes clusters is often quite small -> low IOPS from cloud providers. 🤔
As mentioned previously, this was mostly because Bazel didn't like two targets outputting to the same target - but this is now gone and it's the same value for the production image and for the integration image. As I am writing this I am realizing I can simplify this even more :) |
Ok so made |
Strum355
left a comment
There was a problem hiding this comment.
So long bazel cquery 'somepath(//cmd/server:no_client_bundle.image, //client/web/dist:copy_bundle)' and bazel cquery 'somepath(//cmd/frontend:no_client_bundle.image, //client/web/dist:copy_bundle)' both return an empty set, this LGTM
🥳 |
9a84e82 to
95b62ed
Compare
* Assets now get packaged with the frontend container that is built. * By default the Assets provider will look for an environment variable SRC_ASSETS_DIR and serve assets from there. * Renamed DevProvider to DirProvider
- set mode for assets-dist to 0655 - in integration test also use `assets-dist` dir - comments
95b62ed to
661c1f1
Compare
In https://github.com/sourcegraph/sourcegraph/pull/63946 we reworked how we handle assets, but we overlooked updating the target in `sg.config.yaml`. ## Test plan CI + locally tested (made some changes on the home page, got reloaded as expected)
//client/web/dist:copy_bundletarget to create a tarball for the oci_image.copy_bundleputs all the assets atassets-distno_client_bundletarget variants. For these oci_images, instead of thetar_bundlewhich is just a tar'dcopy_bundlewe use thetar_dummy_manifestwhich is just a tar that contains a dummy manifest./assets-distWhy
By 'breaking' the dependency of frontend requiring assets to be built we essentially stop a common cache invalidation scenario that happens:
By decoupling assets from the frontend binary and moving the packing of assets to the building of the frontend and server images we will have a better cache hit rate (theoretically).
Thus with this change, when:
Closes DINF-115
Test plan
✅ sg start - web app opens and can search. Local dev assets get loaded
✅ sg test bazel-integration-test - server image gets built with only dummy web manifest. Also verified by running
sg bazel run //cmd/server:no_client_bundle.imageand then inspect container✅ sg test bazel-e2e - server image gets built with bundle and all tests pass
✅ main dry run
Changelog
go:embed. Instead assets are now added to the frontend container atassets-dist.