React + Rust + PostgreSQL
A high-performance stack: React on the frontend, a backend written in Rust and PostgreSQL as the database.
Rust compiles to native binaries without a garbage collector, with very low memory usage and memory safety guaranteed by the compiler. Itβs the choice when the workload justifies the extra development effort.
Services included
In addition to your application, the Stack runs PostgreSQL, an nginx that receives traffic on port 80, an automatic backups service and the web file manager.
Project structure
.
βββ backend
β βββ migrations
β β βββ .gitkeep
β β βββ 0001_create-users_down.sql
β β βββ 0001_create-users_up.sql
β βββ src
β β βββ main.rs
β β βββ postgres.rs
β β βββ user.rs
β βββ Cargo.toml
β βββ Dockerfile
βββ backup
β βββ backup-runner.sh
βββ frontend
β βββ public
β β βββ favicon.ico
β β βββ index.html
β β βββ logo192.png
β β βββ logo512.png
β β βββ manifest.json
β β βββ robots.txt
β βββ src
β β βββ App.css
β β βββ App.js
β β βββ App.test.js
β β βββ index.css
β β βββ index.js
β β βββ logo.svg
β β βββ serviceWorker.js
β β βββ setupProxy.js
β β βββ setupTests.js
β βββ Dockerfile
β βββ package-lock.json
β βββ package.json
βββ nginx
β βββ default.conf
βββ .env.example
βββ capture.png
βββ compose.yaml
Getting started
Install the Stack and start it:
docker-deploy-stack --stack javascript/react-rust-postgres
cd /root/stack/javascript/react-rust-postgres
docker compose up -d
Then replace the example application with yours, via Git, by SFTP or from the web file manager, following como-despliego-una-aplicacion-en-un-stack.md. Your code goes in the app/ folder.
Whenever you update the code, apply the changes:
docker compose up -d --build
Configuration
Editable values are in the Stackβs .env file:
| Variable | Default | What itβs for |
|---|---|---|
APP_ENV |
development |
Application environment. |
DB_NAME |
postgres |
Database name. |
DB_USER |
postgres |
Database user. |
BACKUP_ENABLED |
1 |
Automatic backups: 1 enabled, 0 disabled. |
BACKUP_INTERVAL_SECONDS |
86400 |
How many seconds between backups. |
BACKUP_RETENTION_DAYS |
7 |
How many days backups are retained. |
POSTGRES_VERSION |
12-alpine |
Version of the corresponding image. |
After changing it, apply the changes with docker compose up -d.
Useful commands
docker compose ps # view running containers
docker compose logs -f # view live logs
docker compose restart # restart the services
docker compose down # stop and remove the containers