Build and publish large runner docker image - #23345
Conversation
|
Can someone add the AWS_PROJECT_ID secret? I can't because I am not a lead maintainer anymore and lost access to this repo. |
There was a problem hiding this comment.
Pull request overview
Adds automation and container assets to build and publish a “large runner” Docker image derived from the Homebrew brew image, intended to run a self-hosted GitHub Actions runner inside the container.
Changes:
- Add a runner container startup script that configures the runner from a base64-encoded JIT config and starts the runner.
- Add a runner image Docker build context (Dockerfile + entrypoint script).
- Add a GitHub Actions workflow to build multi-arch runner images and publish a manifest (and mirror to AWS/ECR).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
runner/startup.sh |
New entrypoint script to configure the actions runner from RUNNER_JITCONFIG and launch it. |
runner/DockerFile |
New Docker build definition for the runner image based on the Homebrew brew image. |
.gitignore |
Unignore the new runner/ directory so it is committed despite the repo’s “ignore everything then allowlist” approach. |
.github/workflows/runner.yml |
New workflow to build/publish the runner image on successful completion of the existing Docker workflow. |
Comments suppressed due to low confidence (6)
.github/workflows/runner.yml:154
merge_groupis not an event for this workflow (it only runs onworkflow_run), so this condition prevents pushing the manifest. Gate only on thecheckoutput (or remove the condition entirely).
- name: Push manifest
run: |
mapfile -t digest_args < <(find /tmp/digests -maxdepth 1 -type f -printf '%f\n' | sed "s#^#${IMAGE}@sha256:#")
.github/workflows/runner.yml:162
- This workflow runs on
workflow_run, so themerge_groupcheck here will never be true. As a result, the AWS deployment steps are skipped even when a new image was built.
shell: bash
env:
AWS_PROJECT_ID: ${{ secrets.AWS_PROJECT_ID }}
.github/workflows/runner.yml:175
- Same as above: this workflow runs on
workflow_run, sogithub.event_name == 'merge_group'is never true and this step is skipped. Use thecheckoutput to gate publishing.
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_PROJECT_ID }}:role/GithubActionsRoleECRPush
.github/workflows/runner.yml:183
- Same issue: the
merge_groupevent condition is unreachable in aworkflow_run-only workflow, so this login step will be skipped.
- name: Generate AWS image name
env:
.github/workflows/runner.yml:188
- Same unreachable
merge_groupcondition in aworkflow_run-only workflow. Without fixing this,AWS_IMAGEis never set and the push step can't run.
run: |
echo "AWS_IMAGE=${AWS_REGISTRY}/runner-ecr:${BREW_IMAGE_DIGEST}-${GITHUB_SHA}" >> "$GITHUB_ENV"
echo "AWS_IMAGE_LATEST=${AWS_REGISTRY}/runner-ecr:latest" >> "$GITHUB_ENV"
.github/workflows/runner.yml:197
- Same unreachable
merge_groupcondition in aworkflow_run-only workflow; this prevents the image from being pushed to ECR.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with: | ||
| context: runner | ||
| platforms: ${{ matrix.platform }} | ||
| build-args: HOMEBREW_BREW_IMAGE=${{ needs.resolve-base-image.outputs.brew_image }} | ||
| outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} |
| - name: Check if image changed | ||
| if: github.event_name == 'schedule' | ||
| id: check | ||
| run: | |
| if [[ "${config_file}" != "$(basename "${config_file}")" || "${config_file:0:1}" != "." ]]; then | ||
| echo "Invalid file name in JIT config: ${config_file}" >&2 | ||
| continue | ||
| fi |
| # Must be set when running the container (e.g., via `docker run -e RUNNER_JITCONFIG=...`) | ||
| ENV RUNNER_JITCONFIG= | ||
|
|
||
| # Do not let .NET load icu to avoid poluting the image |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks! Few files to move around etc. but good step in the right direction 😍
| @@ -0,0 +1,18 @@ | |||
| ARG HOMEBREW_BREW_IMAGE=ghcr.io/homebrew/brew:main | |||
There was a problem hiding this comment.
When do you want to change this?
| @@ -0,0 +1,53 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Can this script get a comment at the top explaining what it's doing?
| !/README.md | ||
|
|
||
| # Unignore large runner docker folder | ||
| !/runner |
There was a problem hiding this comment.
Let's put this inside .github or Library/Homebrew
| @@ -0,0 +1,53 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Let's ensure this script is put somewhere that brew style is definitely validating its syntax.
| - name: Export digest | ||
| run: | | ||
| mkdir -p /tmp/digests | ||
| digest="${{ steps.build.outputs.digest }}" |
| run: | | ||
| mapfile -t digest_args < <(find /tmp/digests -maxdepth 1 -type f -printf '%f\n' | sed "s#^#${IMAGE}@sha256:#") | ||
| docker buildx imagetools create \ | ||
| --tag "${{ env.IMAGE }}:latest" \ |
|
|
||
| build-runner: | ||
| name: Build runner Docker image (${{ matrix.platform }}) | ||
| needs: merge |
There was a problem hiding this comment.
this could maybe work if we can "pull" from the local image? 🤔 not blocking but maybe worth a try
| needs: merge | |
| needs: build |
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?