Skip to content

Commit

Permalink
fix(docker-compose): ensure mysql starts before xagent-server (OpenBM…
Browse files Browse the repository at this point in the history
…B#294)

- Adjusted the startup sequence in `docker-compose.yml` to prioritize the launch of Redis and MySQL services ahead of xagent-server.
- Enhanced the health check for MySQL service by implementing a more specific method to ensure the database is fully operational before other services start.
  • Loading branch information
Umpire2018 authored Dec 4, 2023
1 parent 040d18d commit b592f73
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: ./
dockerfile: dockerfiles/ToolServerManager/Dockerfile
ports:
- 8080:8080
- "8080:8080"
volumes:
- toolserverconfig:/app/assets/config
- /var/run/docker.sock:/var/run/docker.sock
Expand Down Expand Up @@ -40,29 +40,6 @@ services:
logging:
driver: "none"

XAgentServer:
image: xagentteam/xagent-server:latest
build:
context: ./
dockerfile: dockerfiles/XAgentServer/Dockerfile
container_name: XAgent-Server
env_file:
- .env
environment:
- TOOLSERVER_URL=http://ToolServerManager:8080
- MYSQL_DB_URL=mysql+pymysql://root:xagent@xagent-mysql:3306/xagent
- REDIS_HOST=xagent-redis
volumes:
- ./assets:/app/assets:ro
ports:
- "5173:5173"
- "8090:8090"
depends_on:
xagent-mysql:
condition: service_healthy
xagent-redis:
condition: service_healthy

xagent-mysql:
image: mysql
command:
Expand All @@ -76,7 +53,7 @@ services:
volumes:
- ./XAgentServer/database/sql:/docker-entrypoint-initdb.d
healthcheck:
test: [ "CMD", "mysqladmin","ping", "-h", "localhost" ]
test: ["CMD", "mysql -h localhost -u root -pxagent -e 'SELECT 1'"]
interval: 5s
timeout: 3s
retries: 20
Expand All @@ -91,11 +68,32 @@ services:
interval: 5s
timeout: 3s
retries: 20



XAgentServer:
image: xagentteam/xagent-server:latest
build:
context: ./
dockerfile: dockerfiles/XAgentServer/Dockerfile
container_name: XAgent-Server
env_file:
- .env
environment:
- TOOLSERVER_URL=http://ToolServerManager:8080
- MYSQL_DB_URL=mysql+pymysql://root:xagent@xagent-mysql:3306/xagent
- REDIS_HOST=xagent-redis
volumes:
- ./assets:/app/assets:ro
ports:
- "5173:5173"
- "8090:8090"
depends_on:
xagent-mysql:
condition: service_healthy
xagent-redis:
condition: service_healthy

volumes:
xagentmongodb:
xagentmongodb:
toolserverconfig:
name: toolserverconfig
driver: local
Expand Down

0 comments on commit b592f73

Please sign in to comment.