This repository contains demo code for my YouTube programming learning series about Rust, React, TypeScript, Docker, Terraform and Kubernetes. For this project, we're creating foodi, a meal logging tool.
This project is intended to serve as an example, and can be used as boilerplate for starting your own project. You can also watch the videos to learn more about how it was built (mostly trial and error, like a lot of things in life 😀).
If you'd like to learn more, check out my other projects:
This repo has the following features:
- Rust, Rocket, & SQLx based backend
- React, Mobx, and TypeScript based frontend
- Parcel for frontend packaging
- Docker image with frontend & backend all-in-one
- Terraform for managing a GKE cluster on GCP
- Kubernetes manifest for running on GKE
You can find the videos on YouTube below:
In the series, we're building foodi, a web-based meal logger/tracking tool.
To build the Rust backend, you will need to install the Rust nightly build with rustup. First, go to https://rustup.rs/ and install rustup. Then, install Rust nightly:
$ rustup default nightly
...
Once you have the nightly build installed, you can build the backend.
$ cd foodi-backend
$ cargo build
...
To create the initial database schema, run the migration scripts using
sqlx
:
$ cargo install sqlx-cli
...
$ sqlx migrate run
...
Lastly, you can now run the backend server:
$ cargo run
To build and run the frontend assets and server, you will need a recent version of Node.js and Yarn installed. Using homebrew on macOS, you can install it with homebrew:
$ brew install yarn
...
Install the frontend package dependencies using Yarn:
$ cd foodi-frontend
$ yarn install
...
Use parcel
to run the frontend development server:
$ parcel index.html
...
Assuming you have Docker installed, run the build command from the top level of the repo:
$ docker build . -t foodi:latest
...
Once the build completes, run the container, and map port 80 from inside the container to outside the container on port 8080 (on your host machine):
$ docker run -p 8080:80 foodi:latest
...
🎉 Now you can open http://localhost:8080/
in your browser and test the app.