React + Express + MySQL
React for the frontend, Express on Node.js for the API, and MySQL as the relational database.
This is the MERN stack variant for when data has clear relationships and a schema with referential integrity and SQL queries is preferable.
Services included
In addition to your application, the Stack brings up MySQL, an nginx that receives traffic on port 80, an automatic backups service, and the web file manager.
Project structure
.
βββ .docker
β βββ docker-compose.yaml
βββ backend
β βββ src
β β βββ config.js
β β βββ database.js
β β βββ index.js
β β βββ server.js
β βββ test
β β βββ sample.js
β βββ Dockerfile
β βββ LICENSE
β βββ healthcheck.js
β βββ package-lock.json
β βββ package.json
βββ 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
βββ compose.yaml
Getting started
Install the Stack and bring it up:
docker-deploy-stack --stack javascript/react-express-mysql
cd /root/stack/javascript/react-express-mysql
docker compose up -d
Then replace the example application with yours, from Git, via SFTP, or from the web file manager, following how-do-i-deploy-an-application-on-a-stack.md. Your code goes in the app/ folder.
Each time you update the code, apply the changes:
docker compose up -d --build
Configuration
Editable values are in the Stackβs .env file:
| Variable | Default | Purpose |
|---|---|---|
APP_ENV |
development |
Application environment. |
DB_NAME |
example |
Database name. |
DB_USER |
root |
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. |
MARIADB_VERSION |
10.6.4-focal |
Version of the corresponding image. |
After changing it, apply the changes with docker compose up -d.
Useful commands
docker compose ps # see running containers
docker compose logs -f # view live logs
docker compose restart # restart services
docker compose down # stop and remove containers