-
Notifications
You must be signed in to change notification settings - Fork 28
Cluster Secrets and Buildkit builds #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Can we clean the commits in this PR. There is a lot of back and forth with the docker-compose version and no explanation why. Otherwise the code looks good |
251ffc4 to
b5365d2
Compare
An experiment in changing the rails CI pipeline from "self-hosted" agents to "hosted" agents, a recently release Buildkite feature [1]. The hosted agents linux environment is superficially quite similar to the Elastic Stack for AWS, so the required changes are fairly minimal. Roughly half the changes are to take advantage of some performance optimisations available on hosted agents (like cache volumes, and remote buildkit builders with cache that last across builds). The essential changes: * Read the OCI registry from the environment rather than hard code an ECR registry. The current self-hosted agents run in AWS and can access ECR, but the hosted agent environment has access to its own registry specifically for use cases like this - building an image at the start of the build and then reusing it in later jobs * Changing the queue from `default` or `builder`, to `hosted` Optimisations: * There's no need to use the docker-compose plugins cache_from and image_name shenanigans. The images built at the start of each build use a remote buildkit builder with cache that is s hared between builds. The cache is typically warm, and when it is the image build time drops from ~2 mins to ~18sec * Use plain buildkit to build the images, without the docker compose plugin. This avoids the image being exported from buildkit to docker, and when the buildkit cache is warm the jobs complete in as little as 18s. This bypasses the docker-compse built in support for separating building and running, but the docker-compose.yml already kinda bypasses that by hard coding the image used in the run jobs (using the IMAGE_NAME env var) * ~Create a cache volume for ruby gems that are installed in docker during the initial step. This shaves ~30s off the build time~ [1] https://buildkite.com/docs/pipelines/hosted-agents/overview
This should allow to see, for example, the expected image tag being
built to carry over.
```diff
- - docker-compose#v4.16.0:
+ - docker-compose#v5.0.0:
build: base
config: ".buildkite/docker-compose.yml"
env:
- PRE_STEPS
- RACK
- image-name: ruby-3-4-build_id
cache-from:
- base:973266071021.dkr.ecr.us-east-1.amazonaws.com/builds:ruby-3-4-br-main
push:
- base:973266071021.dkr.ecr.us-east-1.amazonaws.com/builds:ruby-3-4-br-
- image-repository: 973266071021.dkr.ecr.us-east-1.amazonaws.com/builds
```
Notice how the tag is only `ruby-3-4-br-` because the build id was
missing from the environment when generating the pipeline.
b5365d2 to
89ddf20
Compare
|
Thanks for the review. 🙇 Cleaned up git and rebased. This version still uses self-hosted but with placeholders to use the Buildkite hosted infra. Tested using:
I'm not sure the hosted finished, it was queued and I went to bed 😂 Will check back on this later. |
|
I merged this but just realized that the hosted did not work at all. See |
|
Yeah sorry, I'm making time today to work on this. 🙏 |
|
This seems to break CI for rails/rails. Could it be reverted until a fix is made? |
This extracts #141 save for switching the queue to use Buildkite hosted agents.