This project is fully containerized using Docker Compose. All services run in separate containers with nginx handling routing.
- Docker and Docker Compose installed
- A
.envfile in the project root (see.env.examplefor reference)
- Create
.envfile (copy from.env.exampleif it exists):
DB_NAME=tiny_racing
DB_USER=tiny_racing
DB_PASSWORD=tiny_racing_password
DB_PORT=5432
DB_DATA_DIR=./data
DATABASE_URL=postgresql://tiny_racing:tiny_racing_password@postgres:5432/tiny_racing- Build and start all services:
docker-compose up -d --build- Access the application:
- Frontend: http://localhost:8080 (or the port you configured)
- Backend API: http://localhost:8080/api (or the port you configured)
- WebSocket: ws://localhost:8080/ws (or the port you configured)
- postgres: PostgreSQL 16 database
- backend: Rust API server (ports 3000, 3030 internally)
- frontend: Vue.js application (port 80 internally)
- nginx: Reverse proxy routing requests (port 8080 externally by default)
The .env file should contain:
DB_NAME: PostgreSQL database nameDB_USER: PostgreSQL usernameDB_PASSWORD: PostgreSQL passwordDB_PORT: PostgreSQL port (host port mapping)DB_DATA_DIR: Directory for PostgreSQL data persistenceDATABASE_URL: Full database connection URL (used by backend)NGINX_PORT: External port for nginx (default: 8080)BACKEND_API_PORT: External port for backend API (default: 3000)BACKEND_WS_PORT: External port for backend WebSocket (default: 3030)
By default, the application uses:
- Port 8080 for nginx (to avoid conflicts with existing services on port 80)
- Port 3000 for direct backend API access (optional)
- Port 3030 for direct WebSocket access (optional)
To change these ports, add them to your .env file:
NGINX_PORT=8080
BACKEND_API_PORT=3000
BACKEND_WS_PORT=3030If you're running on a server that already has nginx on ports 80/443:
-
Use the default configuration (port 8080) - the application will be accessible at
http://your-server:8080 -
Or configure custom ports in your
.envfile:
NGINX_PORT=9000
BACKEND_API_PORT=9001
BACKEND_WS_PORT=9002- Or proxy through your existing nginx - Add a location block to your main nginx configuration:
location /tiny-racing/ {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /tiny-racing/ws {
proxy_pass http://localhost:8080/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400;
}Then update the frontend build args in docker-compose.yml to use /tiny-racing/api and /tiny-racing/ws as the API/WS URLs.
Database migrations run automatically when the backend starts. The backend waits for the database to be ready before running migrations.
docker-compose downTo also remove volumes (database data):
docker-compose down -v# All services
docker-compose logs -f
# Specific service
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f postgres
docker-compose logs -f nginx# Rebuild specific service
docker-compose build backend
docker-compose up -d backend
# Rebuild all services
docker-compose up -d --build