2023-03-29 12:29:57 -05:00
# Dioxus (& Rocket) - [letter.werefox.cafe](https://letter.werefox.cafe)
2023-03-28 08:21:31 -05:00
2023-03-29 07:43:39 -05:00
> A re-implementation of the Valentine's Day site I made, but using Rust's [Dioxus](https://dioxuslabs.com/) crate and [Rocket](https://rocket.rs/) crate.
2023-03-28 08:21:31 -05:00
## Usage
2023-04-01 15:28:15 -05:00
> This project works by using a Cargo workspace with two projects `rust-letter-fe` and `rust-letter-be`
2023-03-28 08:21:31 -05:00
2023-04-01 15:28:15 -05:00
### Backend
You can develop the backend by simply running the project from the root directory
```
cargo run
```
Generally, any commands you'd use for any other standard Rust project will work for this.
Ex:
2023-03-28 08:21:31 -05:00
```
2023-03-29 07:43:39 -05:00
cargo build
2023-03-28 08:21:31 -05:00
```
2023-04-01 15:28:15 -05:00
### Frontend
If you want to develop the Dioxus frontend, you'll need to do the following:
- [From the official Dioxus docs ](https://dioxuslabs.com/docs/0.3/guide/en/getting_started/web ), ensure you have `dioxus-cli` and the `wasm32-unknown-unknown` target installed
2023-03-28 08:21:31 -05:00
```
2023-04-01 15:28:15 -05:00
cargo install dioxus-cli
2023-03-28 08:21:31 -05:00
```
2023-04-01 15:28:15 -05:00
```
rustup target add wasm32-unknown-unknown
```
- Additionally, you *may* need to have the [Tauri prerequisites ](https://tauri.app/v1/guides/getting-started/prerequisites/ ) installed.
2023-03-28 08:21:31 -05:00
2023-04-01 15:28:15 -05:00
Then, you should be able to run the development server after moving into the `rust-letter-fe` directory.
2023-03-29 12:29:57 -05:00
2023-04-01 15:28:15 -05:00
(Linux example)
2023-03-29 12:29:57 -05:00
```
2023-04-01 15:28:15 -05:00
cd rust-letter-fe & & dioxus serve
2023-03-29 12:29:57 -05:00
```
2023-04-01 15:28:15 -05:00
If you'd link to know about how to use `dioxus-cli` , you should run `dioxus --help` or [reference the official documentation.* ](https://github.com/DioxusLabs/cli )
\* At the time of writing this, the link to the documentation is broken. If you'd like to see what I normally use to run the project, here's an example: `dioxus serve --hot-reload --port [port #]`
2023-03-29 07:43:39 -05:00
2023-04-01 15:28:15 -05:00
## Running
2023-03-29 07:43:39 -05:00
2023-04-01 15:28:15 -05:00
> Here are some ways you can run the project
2023-03-28 08:21:31 -05:00
2023-04-01 15:28:15 -05:00
### Cargo
You can either do the standard `run --release`
```
cargo run --release
```
Or, referencing the Dockerfile, you can install and then run.
```
cargo install --path .
```
2023-03-28 08:21:31 -05:00
```
2023-04-01 15:28:15 -05:00
rust-letter
2023-03-28 08:21:31 -05:00
```
2023-04-01 15:28:15 -05:00
### Docker
2023-03-30 17:39:54 -05:00
You can run this in a container using the included `Dockerfile` .
```
2023-04-01 15:28:15 -05:00
docker build -t rust-letter-werefox-cafe
docker run -p 3469 -d -t rust-letter-werefox-cafe
2023-03-30 17:39:54 -05:00
```
Or, run through docker compose.
```
docker compose up --build -d
```
2023-03-28 08:21:31 -05:00
## Project Structure
```
2023-04-01 15:28:15 -05:00
.dioxus-letter-werefox-cafe
|- data # text files that will be read to for data in the app
|- public # save the assets you want include in your project.
|- rust-letter-be
|\
||- src # source code folder for backend
|- rust-letter-fe
|\
||- src # source code folder for frontend
||\
|||- utils # save some public function
|||- components # save some custom components
|- src # code for running the workspace
|- templates # put template files here, right now just using handlebar
2023-03-28 08:21:31 -05:00
```