Replaces the db service healthcheck command with a custom script and adjusts its parameters for longer timeouts and retries. Also changes the app service's depends_on syntax and adds a restart policy to improve container reliability.
40 行
632 B
YAML
40 行
632 B
YAML
version: "3.8"
|
|
|
|
networks:
|
|
mynet:
|
|
|
|
services:
|
|
web:
|
|
build: .
|
|
env_file:
|
|
- .env
|
|
ports:
|
|
- "80:80"
|
|
volumes:
|
|
- ./:/var/www/html:rw
|
|
command: ["./script.sh"]
|
|
depends_on:
|
|
- db
|
|
networks:
|
|
- mynet
|
|
restart: on-failure
|
|
|
|
db:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile-db
|
|
env_file:
|
|
- .env
|
|
volumes:
|
|
- db_data:/var/lib/mysql
|
|
networks:
|
|
- mynet
|
|
healthcheck:
|
|
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
|
timeout: 30s
|
|
retries: 20
|
|
interval: 15s
|
|
start_period: 60s
|
|
|
|
volumes:
|
|
db_data: {}
|