emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
20.73k stars 1.5k forks source link

Use Trunk to build and deploy demo web app #1937

Open emilk opened 1 year ago

emilk commented 1 year ago

@coderedart did an excellent job converting eframe_template to using Trunk in https://github.com/emilk/eframe_template/pull/69 and it would be great to use Trunk for the egui demo app (egui.rs) too. That way we can deploy a new web app on each commit to master. We can also get rid of a lot of annoying scripts.

omac777 commented 1 year ago

I'm on Fedora Silverblue 36 and was having misery to build egui so I launched a podman container for fedora rawhide.

Here are the steps I did to get it to build and run egui_demo_app successfully within a podman container:

There reference for building egui demo app for wasm: https://github.com/emilk/egui/tree/master/crates/egui_demo_app

start fedora rawhide container:

podman run --net host -i -t fedora:rawhide /bin/bash

inside fedora rawhide container:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
dnf install clang clang-devel clang-tools-extra speech-dispatcher-devel libxkbcommon-devel pkg-config openssl-devel libxcb-devel git-core cmake atk-devel cairo-devel gdk-pixbuf2-devel pango-devel gtk3 gtk3-devel binaryen jq emacs-nox
git clone https://github.com/emilk/egui.git
cd egui/
cargo build --release
cargo install --locked trunk
trunk build --release
./sh/start_server.sh &
./sh/build_demo_web.sh --open
###NOTE it won't be able to open, but it did build the wasm module and placed it in the docs directory.
###Now open in your web browser:  http://localhost:8888/index.html
#############################FINISHED fedora rawhide container

pause podman container: ctrl-p ctrl-q

list podman containers:

podman ps
CONTAINER ID  IMAGE                                         COMMAND               CREATED         STATUS             PORTS       NAMES
b2df210888d6  registry.fedoraproject.org/fedora-toolbox:36  toolbox --log-lev...  4 months ago    Up 3 hours ago                 fedora-toolbox-36
6b0d7a893a84  registry.fedoraproject.org/fedora:rawhide     /bin/bash             56 minutes ago  Up 56 minutes ago              gallant_mahavira

save all our actions and name the container:

podman commit 6b0d7a893a84 fedora-rawhide-rust-egui

kill any running containers:

podman kill 6b0d7a893a84
podman kill b2df210888d6

next time you want to use this container:

docker run --net host -i -t fedora-rawhide-rust-egui /bin/bash
emilk commented 1 week ago

I think one problem here is the multiple_apps.html example/test. I'm not sure trunk supports that use case