Create a houseplant watering tracker for my girlfriend.
trunkyewtailwindclicargo-make (cargo install --force cargo-make)sqlx-cli (cargo install sqlx-cli --no-default-features --features native-tls,postgres)
# Insert the full DATABASE_URL into the environment so sqlx and rust_analyzer
# can pickup the data types from postgresql. This involves a live connection to
# the database. Use SQLX_OFFLINE to avoid this.
source ./scripts/database-url.shRust and docker almost play well together. This project uses docker compsoe to define services for each part of the application.
-
app: the Rust crates:backend,frontend, andcommon. The entire rust project is compiled in the image for this service which can be found indocker/app.Dockerfile. This services eventually starts in adebian:buster-slimimage which runs our application.- First install cargo dependencies
- Use
cargo-chefto generate a static representation of our dependencies so docker can cache them efficiently in a image layer - Compile our project using
cargo-chef(install dependencies) from the recipe it generated in the previous step - Build a release binary for the
backendcrate. This is the web server executable - TODO: Build a bundle from our
frontendcrate. This is the final HTML our server will return. - TODO: Start the server
-
tailwind: Is a service for compiling our tailwind classes infrontend/src/**/*.rsto a single compressed CSS file which can be found infrontend/src/styles/tailwind.css -
db: Starts a postgres database and exposes the port. Right now it does little else. In the future it could:- Backup the database somehow?
- Some logging or database monitoring?
-
kb: TODO: Keybase service which writes to KBChat- Do docker containers communicate effectively across services?
- What data format is used when serializing cross-process communication?
- Persistent data storage between services/container restarts
- Shared data between services
- Better performance than binding to macOS or Windows filesystems
- Cross platform data layer (Linux, Windows, etc.)
- Custom drivers which can automatically write to cloud storage or perform encryption
For the plantbook app, I will probably want a vol_database and vol_tailwind
so that the database contents can be backed up and the tailwind contents can be
read from other services?
Pre-Populating Volumes: to pre-populate a volume with files, we will first need to place the file inside the container. Then when the volume is created for the first time, the contents from the container will be copied over to the shared volume
Jesse Hallett's Talk on Writing GraphQL Servers in Rust from the RustNYC Meetup