https://github.com/nawok/zero-to-production-in-rust
My notes and code for the “Zero to Production in Rust” book by Luca Palmieri
https://github.com/nawok/zero-to-production-in-rust
rust
Last synced: about 2 months ago
JSON representation
My notes and code for the “Zero to Production in Rust” book by Luca Palmieri
- Host: GitHub
- URL: https://github.com/nawok/zero-to-production-in-rust
- Owner: nawok
- Created: 2023-02-27T09:58:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-01T08:25:11.000Z (over 2 years ago)
- Last Synced: 2025-05-24T06:36:45.196Z (5 months ago)
- Topics: rust
- Language: Rust
- Homepage: https://www.zero2prod.com
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Zero to Production in Rust
[](https://github.com/nawok/zero-to-production-in-rust/actions/workflows/general.yml)
[](https://github.com/nawok/zero-to-production-in-rust/actions/workflows/audit.yml)
[](https://codecov.io/gh/nawok/zero-to-production-in-rust)## Faster inner development loop
1. Install an alternative linker for the current OS (see `Cargo.toml`)
2. `cargo install cargo-watch`
3. `cargo watch -x check -x test -x run`## De-occupy the port
```shell
lsof -t -i tcp:8000 | xargs kill -9
```## Expand macros
1. `cargo install cargo-expand`
2. `rustup toolchain install nightly --allow-downgrade`
3. `cargo +nightly expand`## Remove unused dependencies
1. `cargo install cargo-udeps`
2. `cargo +nightly udeps`## Docker
```sh
# Update SQLx schema for offline builds
cargo sqlx prepare -- --lib# Build and run image
docker build --tag zero2prod --file Dockerfile .
docker run -p 8000:8000 --network=host zero2prod
```## Digital Ocean
```sh
# Create app
doctl apps create --spec spec.yaml# Get app ID and URL
app_id=$(doctl apps list | awk '/zero2prod/ {print $1}')
app_url=$(doctl apps list | awk '/zero2prod/ {print $3}')# Update app
doctl apps update $app_id --spec=spec.yaml# Migrate database
DATABASE_URL=$database_url sqlx migrate run# Health check
curl -v $app_url/health_check# Post
curl -v $app_url/subscriptions -d 'name=Le%20Guin&email=ursula%40leguin.com'# Delete
doctl app delete --force $app_id
```