You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Andres Becker c454b83020 working example 1 year ago
api_server working example 1 year ago
web working example 1 year ago
LICENSE updates! 1 year ago working example 1 year ago
docker-compose.yml Taken from the awesome 1 year ago

Rust Web Starter

Pre-configured starter template for web apps using React (create-react-app w/ Typescript) on the frontend and Rust (Rocket, Diesel, & PostgreSQL) on the backend.

Quick Start

Install Docker & Docker-Compose


# clone template into new directory
git clone my-new-project
cd my-new-project

# start it up
docker-compose up

Open http://localhost:3000 (or {docker ip}:3000 on windows) to view it in the browser.

NOTE: If you're on windows you may get an error about bash/r, this has to do with line endings which can be fixed by git config --global core.autocrlf false then cloning again which will clone with unix line endings... Not sure if this is the best answer.

The page will reload if you make edits in the /web folder.

The api server will restart if you make edits in the /api_server folder.

The api layer can be viewed at localhost:3000/api due to the webpack-dev-server proxying setup. (which also means that you can directly use fetch("/api/{whatever}") from the React side and not worry about cross-origin request issues.

Making it your own

After you've tried it out a bit, feel free to steal it! Just remember where it came from and contribute anything really cool back. ;-)

# remove the git repo (could also change remote url if you wanted to keep the history)
rm -rf .git
# init new repo
git init
git add .
git commit -m "initial commit of template from"


I like to use a couple terminals (tabbed) one to run the containers and watch stdout, the other to run any other commands.

Terminal #1

  1. docker-compose up to start
  2. Ctrl+C to stop
  3. Sometimes docker-compose down to dispose of containers

Terminal #2

Examples of useful commands.

  • docker-compose exec api_server bash
    • cargo upgrade
    • diesel setup
    • diesel migration generate {name}
    • diesel migration run
    • diesel migration redo
    • See Rocket & Diesel docs for more.
  • docker-compose exec web bash
  • docker-compose exec db psql -U postgres
    • \list
    • \connect db_name


A small example of Rocket & Diesel usage can be found in /api_server/src/ on this branch.

Calling the api from React can be seen in /web/src/App.tsx


If Rocket ever fails to build with an error concerning nightly version date, this can be fixed by rebuilding the docker container with the latest nightly docker-compose build --no-cache api_server.