The task lifecycle¶
When batect runs a task, there are a number of steps that it follows:
First, it determines which tasks to run and what order to run them in, based on the prerequisites of the requested task and any prerequisites of those prerequisites and so on.
Next, for each task, it determines what containers need to be started for that task, based on the dependency relationships between containers.
Then, it then creates a Docker network for the task, and runs cache initialisation if required.
In parallel to setting up the network and caches, for every container that makes up the task:
- It builds or pulls the image required for this container
- It waits for the task network to be ready
- It waits for cache initialisation to complete, if this container mounts any caches
- It waits for any containers that this container depends on to be ready - so each dependency must have reported as healthy and completed all setup commands
- It starts the container and the container's command
- It waits for the container to report as healthy
- It runs any setup commands, one at a time in the order provided
Once all setup commands have completed, any dependent containers can start.
Once the main container exits, batect then cleans up the containers. This means that, for every container:
- It waits for all containers that depend on this one to stop
- It stops this container
- It removes this container
- It cleans up any temporary files or folders created for this container
Once all containers are removed, the task network is removed and then the task is complete.