| # This file defines an action that builds the various Docker images used to run |
| # libc++ CI whenever modifications to those Docker files are pushed to `main`. |
| # |
| # The images are pushed to the LLVM package registry at https://github.com/orgs/llvm/packages |
| # and tagged appropriately. The selection of which Docker image version is used by the libc++ |
| # CI nodes at any given point is controlled from the workflow files themselves. |
| |
| name: Build Docker images for libc++ CI |
| |
| permissions: |
| contents: read |
| |
| on: |
| push: |
| branches: |
| - main |
| paths: |
| - 'libcxx/utils/ci/docker/**' |
| - '.github/workflows/libcxx-build-containers.yml' |
| pull_request: |
| paths: |
| - 'libcxx/utils/ci/docker/**' |
| - '.github/workflows/libcxx-build-containers.yml' |
| |
| jobs: |
| build-and-push: |
| runs-on: ubuntu-24.04 |
| if: github.repository_owner == 'llvm' |
| permissions: |
| packages: write |
| |
| steps: |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| |
| # The default Docker storage location for GitHub Actions doesn't have |
| # enough disk space, so change it to /mnt, which has more disk space. |
| - name: Change Docker storage location |
| run: | |
| sudo mkdir /mnt/docker |
| echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json |
| sudo systemctl restart docker |
| |
| - name: Build the base image |
| run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder-base |
| env: |
| TAG: ${{ github.sha }} |
| |
| - name: Build the Linux Github Actions image |
| run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder |
| env: |
| TAG: ${{ github.sha }} |
| |
| - name: Build the Android builder image |
| run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-android-builder |
| env: |
| TAG: ${{ github.sha }} |
| |
| - name: Log in to GitHub Container Registry |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| with: |
| registry: ghcr.io |
| username: ${{ github.actor }} |
| password: ${{ secrets.GITHUB_TOKEN }} |
| |
| - name: Push the images |
| if: github.event_name == 'push' |
| run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder |
| env: |
| TAG: ${{ github.sha }} |
| |
| # We create tarballs with the images and upload them as artifacts, since that's useful for testing |
| # the images when making changes. |
| - name: Create image tarballs |
| run: | |
| docker image save ghcr.io/llvm/libcxx-linux-builder-base:${{ github.sha }} | gzip > libcxx-linux-builder-base.tar.gz |
| docker image save ghcr.io/llvm/libcxx-linux-builder:${{ github.sha }} | gzip > libcxx-linux-builder.tar.gz |
| docker image save ghcr.io/llvm/libcxx-android-builder:${{ github.sha }} | gzip > libcxx-android-builder.tar.gz |
| - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| with: |
| name: libcxx-docker-images |
| path: | |
| libcxx-linux-builder-base.tar.gz |
| libcxx-linux-builder.tar.gz |
| libcxx-android-builder.tar.gz |