Skip to content

Commit d35d7f4

Browse files
[Github] Add Agent Container Image (#123486)
This patch adds an agent container image on top of the normal CI container image. They are the exact same except that the agent container image also contains Github Runner binaries. I've split it into a separate container as only one user of these images (the new premerge) needs this binary installed, and it bloats the container image size significantly (900MB->1.3GB or so).
1 parent e68d18c commit d35d7f4

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: .github/workflows/build-ci-container.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,22 @@ jobs:
3636
tag=`date +%s`
3737
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
3838
echo "container-name=$container_name" >> $GITHUB_OUTPUT
39+
echo "container-name-agent=$container_name-agent" >> $GITHUB_OUTPUT
3940
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
41+
echo "container-name-agent-tag=$container_name-agent:$tag" >> $GITHUB_OUTPUT
4042
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
4143
- name: Build container
4244
working-directory: ./.github/workflows/containers/github-action-ci/
4345
run: |
44-
podman build -t ${{ steps.vars.outputs.container-name-tag }} .
46+
podman build --target ci-container -t ${{ steps.vars.outputs.container-name-tag }} .
47+
podman build --target ci-container-agent -t ${{ steps.vars.outputs.container-name-agent-tag }} .
4548
4649
# Save the container so we have it in case the push fails. This also
4750
# allows us to separate the push step into a different job so we can
4851
# maintain minimal permissions while building the container.
4952
- name: Save container image
5053
run: |
51-
podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
54+
podman save ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name-agent-tag }} > ${{ steps.vars.outputs.container-filename }}
5255
5356
- name: Upload container image
5457
uses: actions/upload-artifact@v4
@@ -86,3 +89,7 @@ jobs:
8689
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
8790
podman push ${{ needs.build-ci-container.outputs.container-name-tag }}
8891
podman push ${{ needs.build-ci-container.outputs.container-name }}:latest
92+
93+
podman tag ${{ needs.build-ci-container.outpus.container-name-agent-tag }} ${{ needs.build-ci-container.outputs.container-name-agent }}:latest
94+
podman push ${{ needs.build-ci-container.outputs.container-name-agent-tag }}
95+
podman push ${{ needs.build-ci-container.outputs.container-name-agent }}:latest

Diff for: .github/workflows/containers/github-action-ci/Dockerfile

+12-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RUN cmake -B ./build -G Ninja ./llvm \
3939

4040
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution
4141

42-
FROM base
42+
FROM base as ci-container
4343

4444
COPY --from=stage1-toolchain $LLVM_SYSROOT $LLVM_SYSROOT
4545

@@ -92,4 +92,15 @@ RUN adduser gha sudo
9292
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
9393

9494
USER gha
95+
WORKDIR /home/gha
96+
97+
FROM ci-container as ci-container-agent
98+
99+
ENV GITHUB_RUNNER_VERSION=2.321.0
100+
101+
RUN mkdir actions-runner && \
102+
cd actions-runner && \
103+
curl -O -L https://github.com/actions/runner/releases/download/v$GITHUB_RUNNER_VERSION/actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz && \
104+
tar xzf ./actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz && \
105+
rm ./actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz
95106

0 commit comments

Comments
 (0)