Help Center

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

text
.
β”œβ”€β”€ 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:

bash
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:

bash
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

bash
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
Guide g.0297 Β· Source version 1 Β· en