Quando executei o comando docker compose up --build no terminal, ele efetuou o build, criou o container e no final do terminal me apontou a falha "dependency failed to start: container codechella-api-mysql-1 is unhealthy", após isso ao iniciar a aplicação no docker, o erro de conexão com o mySql continuou acontecendo. Segue os aquivos de configuração do docker:
docker-compose.yml
version: '3'
services:
mysql:
image: mysql:8.0.36
env_file: ./env/mysql.env
volumes:
- ./mysql-data:/var/lib/mysql
restart: unless-stopped
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
interval: 5s
timeout: 5s
retries: 10
app:
build:
context: .
env_file: ./env/app.env
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
volumes:
mysql-data:
app.env
SPRING_PROFILES_ACTIVE=prod
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/codechella
SPRING_DATASOURCE_USERNAME=codechella_user
SPRING_DATASOURCE_PASSWORD=codechella_pwd
MAIL_HOST=smtp.gmail.com
MAIL_USER=mail_user
MAIL_PASSWORD=mail_pwd
APP_JWT_SECRET=jwt_secret
mysql.env
MYSQL_RANDOM_ROOT_PASSWORD=true
MYSQL_DATABASE=codechella
MYSQL_USER=codechella_user
MYSQL_PASSWORD=codechella_pwd