score-spec / score-compose

Reference implementation for docker-compose target platform support
https://docs.score.dev/docs/score-implementation/score-compose/
Apache License 2.0
446 stars 42 forks source link

fix: improve depends-on condition for wait-for-resources #165

Closed astromechza closed 3 months ago

astromechza commented 3 months ago

I found an interesting condition with the wait-for-resources service when doing a command like docker compose up <some-service> --wait:

$ docker compose up hello-world-first --wait
[+] Running 3/3
 ✔ Container 12-mysql-database-mysql-8MjJEo-1        Healthy                                                                                                                                                                                                                    0.0s 
 ✔ Container 12-mysql-database-wait-for-resources-1  Created                                                                                                                                                                                                                    0.0s 
 ✔ Container 12-mysql-database-hello-world-first-1   Healthy                                                                                                                                                                                                                    0.2s 
container 12-mysql-database-wait-for-resources-1 exited (0)
$ echo $?
1

Note the non-zero exit code!

So this PR fixes it and moves to a more reasonable code.

$ docker compose up hello-world-first --wait
[+] Running 3/3
 ✔ Container 12-mysql-database-mysql-8MjJEo-1        Healthy                                                                                                                                                                                                                    0.0s 
 ✔ Container 12-mysql-database-wait-for-resources-1  Exited                                                                                                                                                                                                                     0.0s 
 ✔ Container 12-mysql-database-hello-world-first-1   Healthy    
$ echo $?
0