WangYihang commented on issue #1206:
URL: https://github.com/apache/answer/issues/1206#issuecomment-3815465092
Here is a more stable solution: waiting for the init SQL file (`app.sql`)
been successfully imported into the MySQL instance, then start the Anwser
server.
```yaml
services:
app:
image: apache/answer:1.7.1
ports:
- '9080:80'
restart: on-failure
volumes:
- ./config.yaml:/data/conf/config.yaml
depends_on:
mysql:
condition: service_healthy
mysql:
image: mysql:8.0
restart: on-failure
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=app
- MYSQL_USER=user
- MYSQL_PASSWORD=changeme!
volumes:
- ./app.sql:/docker-entrypoint-initdb.d/app.sql
- mysql_data:/var/lib/mysql
healthcheck:
# check if `app.sql` is already imported by checking if the table
`x_users` exists.
test: [ "CMD-SHELL", "mysql -u user -pchangeme! -D app -e 'SELECT 1
FROM x_users LIMIT 1;'" ]
interval: 16s
timeout: 16s
retries: 16
start_period: 32s
volumes:
mysql_data:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]