You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
Simplifies usage of [Docker Compose](https://www.docker.com/docker-compose) for local development and integration testing in [Gradle](https://gradle.org/) environment.
5
5
6
-
`composeUp` task starts the application and waits till all exposed TCP ports are open (so till the application is ready). It reads assigned host and ports of particular containers and stores them into `dockerCompose.servicesInfos` property.
6
+
`composeUp` task starts the application and waits till all containers become [healthy](https://docs.docker.com/engine/reference/builder/#/healthcheck) and all exposed TCP ports are open (so till the application is ready). It reads assigned host and ports of particular containers and stores them into `dockerCompose.servicesInfos` property.
7
7
8
8
`composeDown` task stops the application and removes the containers.
9
9
@@ -14,8 +14,8 @@ Simplifies usage of [Docker Compose](https://www.docker.com/docker-compose) for
14
14
## Why this plugin?
15
15
You could easily ensure that `docker-compose up` is called before your tests but there are few gotchas that this plugin solves:
16
16
17
-
1. If you execute `docker-compose up -d` (_detached_) then this command returns immediately and your application is probably not able to serve requests at this time. This plugin waits till all exported TCP ports of all services are open.
18
-
- If waiting for open TCP ports timeouts (default 15 minutes) then it prints log of related service.
17
+
1. If you execute `docker-compose up -d` (_detached_) then this command returns immediately and your application is probably not able to serve requests at this time. This plugin waits till all containers become [healthy](https://docs.docker.com/engine/reference/builder/#/healthcheck) and all exported TCP ports of all services are open.
18
+
- If waiting for healthy state or open TCP ports timeouts (default is 15 minutes) then it prints log of related service.
19
19
2. It's recommended not to assign fixed values of exposed ports in `docker-compose.yml` (i.e. `8888:80`) because it can cause ports collision on integration servers. If you don't assign a fixed value for exposed port (use just `80`) then the port is exposed as a random free port. This plugin reads assigned ports (and even IP addresses of containers) and stores them into `dockerCompose.servicesInfo` map.
20
20
21
21
# Usage
@@ -63,7 +63,7 @@ test.doFirst {
63
63
# Tips
64
64
* You can call `dockerCompose.isRequiredBy(anyTask)` for any task, for example for your custom `integrationTest` task.
65
65
* If some Dockerfile needs an artifact generated by Gradle then you can declare this dependency in a standard way, like `composeUp.dependsOn project(':my-app').distTar`
66
-
* All properties in `dockerCompose` have meaningfull default values so you don't have to touch it. If you are interested then you can look at [ComposeExtension.groovy](/src/main/groovy/com/avast/gradle/dockercompose/ComposeExtension.groovy) for reference.
66
+
* All properties in `dockerCompose` have meaningful default values so you don't have to touch it. If you are interested then you can look at [ComposeExtension.groovy](/src/main/groovy/com/avast/gradle/dockercompose/ComposeExtension.groovy) for reference.
67
67
*`dockerCompose.servicesInfos` contains information about running containers so you must access this property after `composeUp` task is finished. So `doFirst` of your test task is perfect place where to access it.
68
68
* Plugin honours a `docker-compose.override.yml` file, but only when no files are specified with `useComposeFiles` (conform command-line behavior).
69
69
* Check [ServiceInfo.groovy](/src/main/groovy/com/avast/gradle/dockercompose/ServiceInfo.groovy) to see what you can know about running containers.
logger.lifecycle("${service.name} healh state reported as '$healthStatus' - continuing...")
175
+
return
176
+
}
177
+
} else {
178
+
logger.debug("Service ${service.name} or this version of Docker doesn't support healtchecks")
179
+
return
180
+
}
181
+
if (start.plus(extension.waitForHealthyStateTimeout) <Instant.now()) {
182
+
thrownewRuntimeException("Container ${service.containerId} of service ${service.name} is still reported as 'starting'. Logs:${System.lineSeparator()}${getServiceLogs(service.name)}")
183
+
}
184
+
logger.lifecycle("Waiting for ${service.name} to become healthy")
0 commit comments