firstly I'd like to say that this topic might be related to others, but I can't find a solution for this specific error.
Remembering that this error happens ONLY when I execute my ./mvnw test within the Dockerfile stage and on CI.
Dockerfile:
FROM eclipse-temurin:18.0.2.1_1-jdk-alpine AS test
ENV spring_profiles_active=test
ENV APP=/home/fvapi
WORKDIR $APP
COPY pom.xml mvnw ./
COPY .mvn .mvn
COPY src src
RUN ./mvnw test
On CI it just clones the repo and execute the same ./mvnw test.
The error is a loop, and you can see it here: https://pastebin.com/ar5BPXvp
I think the main point here is:
2022-09-14 04:05:46.254 INFO 131 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
2022-09-14 04:06:17.298 ERROR 131 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-2 - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
I have already tried looking for anything related to both HikariPool-2 - Exception during pool initialization, loop HikariPool-2 - Starting and to the com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure, but I found nothing relevant.
I also tried these application.properties
spring.datasource.url=jdbc:mysql://DATABASE_URL_FROM_AWS_RDS/dbname
spring.datasource.username=admin
spring.datasource.password=password
spring.datasource.platform=mysql
spring.jpa.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
and also
spring.datasource.url=jdbc:mysql://DATABASE_URL_FROM_AWS_RDS/dbname?useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=admin
spring.datasource.password=password
spring.datasource.platform=mysql
spring.jpa.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
Can someone please give me a light?
PS.: this error only happens when running using docker and on CI. If I try locally, it works.