2.6 KiB
Drivers Hub: Docker Deployment
____ _ __ __ __
/ __ \_____(_) _____ __________ / / / /_ __/ /_
/ / / / ___/ / | / / _ \/ ___/ ___/ / /_/ / / / / __ \
/ /_/ / / / /| |/ / __/ / (__ ) / __ / /_/ / /_/ /
/_____/_/ /_/ |___/\___/_/ /____/ /_/ /_/\__,_/_.___/
Docker deployment for Drivers Hub: Backend. The deployment includes MariaDB, Valkey, and the banner generator.
Configure the deployment
Get the backend source code. Then, create the deployment configuration and the application configuration:
git clone https://github.com/CharlesWithC/HubBackend.git upstream/HubBackend
cp .env.example .env
cp upstream/HubBackend/config_sample.json config/config.json
Set secure MariaDB passwords in .env. Then, set at least these values in
config/config.json:
{
"abbr": "drivershub",
"name": "Drivers Hub",
"domain": "localhost",
"prefix": "/api",
"server_host": "0.0.0.0",
"server_port": 7777,
"db_host": "mariadb",
"db_user": "drivershub",
"db_password": "use the DB_PASSWORD value from .env",
"db_name": "drivershub",
"db_data_directory": "/var/lib/mysqlext/",
"redis_host": "valkey",
"redis_port": 6379
}
The example shows only the values that you must change. Keep all other values
from config_sample.json. Restart the backend after you change
config/config.json.
Use the same database password in .env and config/config.json.
Start the deployment
docker compose build
docker compose up -d
docker compose ps
By default, the API is available at http://localhost:7777/api. Swagger UI is
available at http://localhost:7777/api/doc.
Store persistent data
The deployment stores all persistent data in these directories:
data/
├── mariadb/
├── mariadb-external/
└── valkey/
Docker creates these directories at the first start. MariaDB and Valkey do not publish ports on the host.
The docker compose down command removes the containers and the network. It does
not remove config/ or data/. Back up these directories separately.
Update the backend
Update the backend source code. Then, rebuild the containers:
git -C upstream/HubBackend pull --ff-only
docker compose build
docker compose up -d
Operate the deployment
# Show the backend logs.
docker compose logs -f backend
# Restart the backend after a configuration change.
docker compose restart backend
# Create a user.
docker compose run --rm backend \
drivershub --config /app/config/config.json setup create-user user@example.com