https://github.com/ltfschoen/kobold-test
Basic website using rustlang
https://github.com/ltfschoen/kobold-test
docker kobold rust shell-script trunk
Last synced: 3 months ago
JSON representation
Basic website using rustlang
- Host: GitHub
- URL: https://github.com/ltfschoen/kobold-test
- Owner: ltfschoen
- License: lgpl-3.0
- Created: 2023-03-17T00:40:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T13:29:46.000Z (over 3 years ago)
- Last Synced: 2025-02-02T03:43:26.010Z (over 1 year ago)
- Topics: docker, kobold, rust, shell-script, trunk
- Language: Shell
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kobold Test
Testing the capabilities of Kobold library whilst learning Rust.
### Initial Setup Log
* Added example rust-toolchain.toml
* Install Rust https://doc.rust-lang.org/cargo/getting-started/installation.html
* Update Rust and Cargo
```bash
rustup update
cargo update
```
* Switch to latest "stable" Rustup
```bash
rustup override set stable-x86_64-unknown-linux-gnu
```
* Install Kobold dependencies https://github.com/maciejhirsz/kobold#more-examples
```bash
rustup target add wasm32-unknown-unknown
```
* Switch to default [Rustup Profile](https://rust-lang.github.io/rustup/concepts/profiles.html)
```bash
rustup set profile default
```
* Check Rustup Configuration
```bash
rustup toolchain list
rustup show
```
* Add additional components
```bash
rustup component add rustc cargo rustfmt rust-std rust-docs clippy miri rust-src llvm-tools-preview
```
* Created project
```bash
cargo new kobold-test --bin
cargo add kobold
touch index.html
```
* Paste the following in index.html
```bash
Kobold Hello World example
```
* Paste the following in ./src/main.rs
```bash
use kobold::prelude::{component, html, Html};
#[component]
fn Hello(name: &str) -> impl Html + '_ {
html! {
"Hello "{ name }"!"
}
}
fn main() {
kobold::start(html! {
});
}
```
* Install [Trunk](https://trunkrs.dev/#getting-started)
* Create Trunk.toml & Paste:
```bash
[tools]
wasm_bindgen = "0.2.84"
```
* Build, watch and serve the Rust WASM web application and all its assets. Automatically opens in web browser.
```bash
trunk serve --address=127.0.0.1 --open
```
* Note: Replace with public IP address to access externally if firewall permissions allow
### Docker
* Runs server inside Docker container. Build artifacts dist/ and target/ are generated inside the Docker container with hot reloading.
* Install and run [Docker](https://www.docker.com/)
* Run in Docker container
```bash
./docker-dev.sh
```
* View website http://:8080
* Kill Docker container
```
docker stop kobold-test && docker rm -f kobold-test
```
### Troubleshooting
* The following was used to test if all binaries and examples and packages specified could be installed.
```bash
cargo install --bins --examples --git=https://github.com/ltfschoen/kobold --branch=master --rev=2617dc3e4cff227d68e8a7ae883d8aa7cec6de6f kobold_counter_example kobold_csv_editor_example kobold_hello_world_example kobold_interval_example kobold_list_example kobold_qrcode_example kobold_stateful_example kobold_todomvc_example --verbose
```
However the Cargo.toml file was updated as follows instead so it would run without error when `trunk serve`
```
[dependencies]
# https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations
kobold = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
kobold_macros = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
kobold_qr = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
```
* rust-toolchain file
* It still isn't possible to install the toolchain and components specified in a rust-toolchain.toml file because. See
* https://github.com/rust-lang/rustup/issues/2686
* https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml#L11
* https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file