diff --git a/README.md b/README.md index 3a29eb0..a085682 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,17 @@ The latest prototype is in the folder `app-proto`. It includes both a user inter 1. Go into the `app-proto` folder 2. Call `cargo test` + +### Deploy the prototype + +1. From the `app-proto` folder, call `trunk build --release`. + - Building in [release mode](https://doc.rust-lang.org/cargo/reference/profiles.html#release) produces an executable which is smaller and often much faster, but harder to debug and more time-consuming to build. +2. Use `bash` to run the packaging script `tools/package-for-deployment.bash`. + - The script is location-independent, so you can do this from anywhere in the dyna3 repository. + - The call from the top level of the repository is: + ```bash + bash tools/package-for-deployment.bash + ``` + - This will overwrite or replace the files in `deploy/dyna3`. +3. Put the contents of `deploy/dyna3` in the folder on your server that the prototype will be served from. + - To simplify uploading, you might want to combine these files into an archive called `deploy/dyna3.zip`. Git has been set to ignore this path. \ No newline at end of file diff --git a/app-proto/Trunk.toml b/app-proto/Trunk.toml new file mode 100644 index 0000000..017deba --- /dev/null +++ b/app-proto/Trunk.toml @@ -0,0 +1,2 @@ +[build] +public_url = "./" \ No newline at end of file diff --git a/deploy/.gitignore b/deploy/.gitignore new file mode 100644 index 0000000..192f529 --- /dev/null +++ b/deploy/.gitignore @@ -0,0 +1,5 @@ +/dyna3.zip +/dyna3/index.html +/dyna3/dyna3-*.js +/dyna3/dyna3-*.wasm +/dyna3/main-*.css \ No newline at end of file diff --git a/tools/package-for-deployment.bash b/tools/package-for-deployment.bash new file mode 100644 index 0000000..743a508 --- /dev/null +++ b/tools/package-for-deployment.bash @@ -0,0 +1,16 @@ +# set paths. this technique for getting the script location comes from +# `mklement0` on Stack Overflow +# +# https://stackoverflow.com/a/24114056 +# +tools=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") +src="$tools/../app-proto/dist" +dest="$tools/../deploy/dyna3" + +# remove the old hash-named files +[ -e "$dest"/dyna3-*.js ] && rm "$dest"/dyna3-*.js +[ -e "$dest"/dyna3-*.wasm ] && rm "$dest"/dyna3-*.wasm +[ -e "$dest"/main-*.css ] && rm "$dest"/main-*.css + +# copy the distribution +cp -r "$src/." "$dest"