m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.96k stars 449 forks source link

How to rebuild with UI changes? #287

Closed innerop closed 1 year ago

innerop commented 1 year ago

Hi,

Trying to test trivial mods in the UI, changed some Vue files, and rebuilt base, but nothing changes when I start it again with docker compose up.

How do I incoporate changes such that I see them when I run it with docker-compose?

m1k1o commented 1 year ago

If you built base don't forget to rebuild the other image that extends base.

If for testing, you could either start ./serve-client in .docker and see live changes, or you could build only client with npm run build and mount the dist/ file to your neko container under /var/www.

innerop commented 1 year ago

Works, but it feels like there should be 3 docker images:

1) base (server?) 2) app (e.g. firefox, chrome etc) 3) client (vue)

Seems like the vue ui is part of the app image? or in both base and app?

m1k1o commented 1 year ago

Client is only artifact, creates static files and neko server only serves them. And its part of the base.

innerop commented 1 year ago

Why are the changes I made for vue client depend on building the browser image? Shouldn't building the base be enough?

m1k1o commented 1 year ago

Because browser image depends on base image. And that dependency is resolved when building browser image.

innerop commented 1 year ago

ok, maybe the static files are in the base and the browser image needs to be rebuilt because it incorporates the base and it's the final layer? I guess that makes sense in the docker model because there is one container after all, not two. For some reason that was not obvious. I thought maybe the base image was its own container, and the browser image was its own container too and you had a 3rd image that dynamically loaded both containers, but I don't thikn that's possible with docker.

innerop commented 1 year ago

I guess my thinking was why not have an app image that pulls the base image and the browser image. This way, it's obvious that we have to rebuild the app image because it is the final definition of the container. If we have many other images to build but we only changed one image, e.g. base, we won't have to build all the chain of images that depend on it. We would just rebuild the app image which pulls in those other images including the one we rebuilt (must invalidate cache for that one)

m1k1o commented 1 year ago

You cannot have one image that is based on two images. However, they could be separate independent containers. And you would need to start both of them. I had something like this in mind, but it would create some overhead in deploying two containers and have them communicate properly. For now most of the people prefer taking base container and building on top of that, what results in a singe image that can be deployed.

innerop commented 1 year ago

Ok, you can pull from any number of images in a Dockerfile but you can only build a container based on one image, so it's possible to COPY the artifacts needed from a previous stage that is built in the same Dockerfile. I think it's called a multi-stage build. Closing for now, and if I have time I can make a demo. But there are so many other areas and open PRs like h265 support that warrant more attention:)

m1k1o commented 1 year ago

We already have multi stage build as base, copying artifacts (server binary an client files). But the base is more than that. Its the whole environment that allows running the desired app.

You could theoretically just replace server binary and client files. Thats what we do in ./rebuild-server, and then in ./server-start we just mount that binary to existing environment.

innerop commented 1 year ago

yes, i meant for the docker usage experience, if there was a neko-app image that pulled the browser image and built a container from the base then copied over the browser artifacts then when the client or server changes we rebuild base and the neko-app and if the browser image hasn't changed we won't have to rebuild it again. Right now we do have to rebuild it even when it hasn't changed. I can do that in my local fork, no worries. I realize the way you set it up for fast iteration on development but I'm just concerned with the docker usage right now. No worries. There are more important things like h265 support. I'm using a non-GPU server and the rendering could be a bit better.

m1k1o commented 1 year ago

I agree with you that apps and base should be split and separately updated. If you figure out a way how to acheive that, feel free to open PR. Any topic you mentioned is welcome.