A solution to scale (up & down) docker runners on a macos/windows/linux system.
Prerequsites:
- You will need an active runner on a machine that has docker installed, for instance, I used my MacBook, but you can use an Ubuntu EC2 Instance.
- Populate your CCI project env vars with the following, and populate with the correct infomation:
- RESOURCE_CLASS = Your docker runners resource-class
- DOCKER_RESOURCE_TOKEN = Your docker runners resource-class token
- CIRCLE_TOKEN = Your CCI API token
- DOCKER_IMAGE_ID = The image ID of whatever docker image you want your resource-class to use
Once you have done the above, you should be able to run the pipeline and watch as your containers spin up based on how many waiting tasks you have for a specified resource-class.
Once no more tasks are running for that resource-class, the containers will be removed.
Scaling script polling for waiting jobs: