Skip to content

Commit 6d8ca24

Browse files
Ashish MishraAshish Mishra
authored andcommitted
adding healthcheck for mysql container to accpet conenction after 100% spin up
1 parent 2c92f76 commit 6d8ca24

3 files changed

Lines changed: 7 additions & 23 deletions

File tree

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ WORKDIR /springApplication/app
1616
# Copy the jar file from the builder stage
1717
COPY --from=JARBUILDER /build/target/*.jar app.jar
1818

19-
# Copy wait-for.sh into the image
20-
COPY wait-for.sh .
2119

22-
# Make the script executable
23-
RUN chmod +x wait-for.sh
24-
25-
# Use wait-for.sh as entrypoint
26-
ENTRYPOINT ["./wait-for.sh", "mysql-service", "java", "-jar", "app.jar"]
20+
# Use entrypoint
21+
ENTRYPOINT ["java", "-jar", "app.jar"]

docker-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ services:
1818
volumes:
1919
- ./src/main/resources/dockerizedEntireApp/init-script:/docker-entrypoint-initdb.d
2020
# - ./src/main/resources/dockerizedEntireApp/volumes/mysql_data:/var/lib/mysql
21+
healthcheck:
22+
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
23+
interval: 10s
24+
timeout: 5s
25+
retries: 5
2126
profiles:
2227
- entireApp
2328
networks:

wait-for.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)