Here's an actix-web template that uses SvelteKit built and served as static files.
- Actix web server
- Diesel.rs ORM with migrations, and r2d2 for connection pooling
- SvelteKit for frontend, served as static files
We use Vite's proxy in the dev environment and serve svelte as static files in production.
- cargo:
curl https://sh.rustup.rs -sSf | sh
- diesel_cli:
cargo install diesel_cli --no-default-features --features sqlite
- node: https://nodejs.org/en/download/current/
- sqlite3:
apt install sqlite3 libsqlite3-dev
diesel setup
diesel migration run
npm run dev
All traffic to localhost:3000/api/* will be forwarded to the actix web project, and anything else to the SvelteKit frontend.
You can build the project with cargo. The build.rs
will automatically compile the frontend to static files in the ./client/build directory.
cargo build --release
For convenience a Dockerfile was created which handles compiling the frontend to static files and building the Actix Web server into a 20mb Alpine image.
docker build -t actix-svelte-template .
docker run -d -p 8080:8080 actix-svelte-template