- 🦀 Crab Rocket
A web backend server written in Rust and based on Rocket.
- Rust
- Rocket
- Diesel
- dotenvy
- serde_json
- chrono
- Rust 2021 environment
- PostgreSQL
# Install Diesel CLI
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/diesel-rs/diesel/releases/download/v2.2.1/diesel_cli-installer.sh | sh
cd ./modules/cb_schema
# Setup Diesel
diesel setup
# Redo and run migrations
diesel migration redo
diesel migration run
# Run the server
cargo run
!!! Everytime run cargo test
should run diesel database reset
first.
cargo build --release
cargo install --path .
Set the environment variable:
export DATABASE_URL=postgres://@localhost/hello_rocket
Alternatively, update the .env
file in the project root.
diesel database reset
crab_rocket
docker build -t crab_rocket .
docker run --name crab_rocket_demo --rm -p 8000:8000 crab_rocket
mise run r
Configured in .mise.config.toml
- Ensure the sequence of fields in structs matches the database schema exactly.
- Mismatches may lead to errors in
Queryable
.
cargo install toast
docker build -t crab_rocket .
toast
version: "3.1"
services:
db:
image: postgres
ports:
- "5432:5432"
restart: always
environment:
POSTGRES_PASSWORD: changemeinpred!
pip install posting
posting --collection ./posting
cargo install cross --git https://github.com/cross-rs/cross
Install toolchains for specific target platforms:
rustup target add aarch64-apple-darwin
# (ONCE PER BOOT, on Linux)
# Start Docker daemon (Systemd for WSL2 and SysVinit for other systems)
sudo systemctl start docker
# Build for aarch64
cross build --target aarch64-unknown-linux-gnu
# Test for mips64
cross test --target mips64-unknown-linux-gnuabi64
# Build with LTO for powerpc
cross rustc --target powerpc-unknown-linux-gnu --release -- -C lto