router-dashboard/docker-compose.yml
shankar 8630a3e2c5 Fixed React backend startup issue.
Updated SQL script to correct procedure and column sizes.
Moved SQL scripts to the project root folder (outside React frontend).
Resolved backend container dependency issue to ensure MySQL is up before starting React backend.
Moved common values to .env file in the project root.
Updated React backend and MySQL ports to use default values.
Added code to get last study received, containers status and updated into DB.
2024-11-22 13:44:03 +05:30

65 lines
1.7 KiB
YAML

version: '3.8'
services:
frontend:
build:
context: ./router-dashboard
dockerfile: dockerfile
ports:
- "5173:5173"
environment:
- VITE_API_URL=${VITE_API_URL}
restart: always
depends_on:
backend:
condition: service_healthy
container_name: router_dashboard_frontend
backend:
build:
context: ./ve-router-backend
dockerfile: dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=${NODE_ENV}
- DB_HOST=host.docker.internal
- DB_PORT=3306
- DB_USER=ve_router_user
- DB_PASSWORD=ve_router_password
- DB_NAME=${DB_NAME}
restart: always
depends_on:
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "3000"] # Netcat check to see if port 3000 is open
interval: 30s # Check every 30 seconds
retries: 3 # Retry 3 times before marking unhealthy
start_period: 30s # Wait 30 seconds before starting health checks
timeout: 10s # Wait for 10 seconds for each health check to respond
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: ve_router_db
MYSQL_USER: ve_router_user
MYSQL_PASSWORD: ve_router_password
volumes:
- mysql_data:/var/lib/mysql
# Correct paths for init scripts
- ./sql:/docker-entrypoint-initdb.d
ports:
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
restart: always
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "ve_router_user", "-pve_router_password"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
volumes:
mysql_data: