ThomasVitale / cloud-native-spring-in-action

🍃 Code samples and projects from the book "Cloud Native Spring in Action - With Spring Boot and Kubernetes" (Manning)
https://www.manning.com/books/cloud-native-spring-in-action
Apache License 2.0
426 stars 257 forks source link

Chapter 7: Fails to build docker image with Tilt #61

Closed elR1cu closed 4 months ago

elR1cu commented 9 months ago

Hi, I can successfully build the catalog-service image locally when I run the maven command. All is fine, and testcontainers ITs are ok. However, when I try to build the image with Tilt, I get a problem with testcontainers when running integration tests :

2024-01-25T09:27:58.911+01:00  WARN 2867 --- [catalog-service] [containers-ryuk] o.t.utility.RyukResourceReaper           : Can not connect to Ryuk at 127.0.0.1:32768

java.net.ConnectException: Connection refused
    at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na]
    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:682) ~[na:na]
    at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549) ~[na:na]
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592) ~[na:na]
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[na:na]
    at java.base/java.net.Socket.connect(Socket.java:751) ~[na:na]
    at org.testcontainers.utility.RyukResourceReaper.lambda$null$1(RyukResourceReaper.java:105) ~[testcontainers-1.19.3.jar:1.19.3]
    at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27) ~[duct-tape-1.0.8.jar:na]
    at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$2(RyukResourceReaper.java:101) ~[testcontainers-1.19.3.jar:1.19.3]
    at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]

Any idea ? Thanks a lot !

elR1cu commented 9 months ago

I've tried with the gradle command, and it seems the tests are not run. According to this, the equivalent maven command to gradle bootBuildImage is mvn spring-boot:build-image but the latter run all the preceding phases to package phase, so also the test phase. According to Spring Boot Maven documentation, the equivalent command would be instead mvn spring-boot:build-image-no-fork. In this case, no tests are run and just the image is built. Or instead mvnw spring-boot:build-image -DskipTests.

@ThomasVitale does it make sense for you to update the Gradle and Maven section ?

ThomasVitale commented 4 months ago

@elR1cu thanks a lot for reporting this inconsistency between Gradle and Maven. I have updated the table in the README.md file accordingly: https://github.com/ThomasVitale/cloud-native-spring-in-action/commit/3b19d02bea585c376501c1c10412f2bba0ecbff0