From 201302513cc5aa74c3f33e5d0458c545aecfa6b9 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 27 Nov 2023 15:54:44 -0800 Subject: [PATCH] Add x86_64 cpu builder gh image. --- .../workflows/publish_cpubuilder_x86_64.yml | 44 ++++++++++++++++++ README.md | 13 ++++++ ...builder_ubuntu_jammy_ghr_x86_64.Dockerfile | 45 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .github/workflows/publish_cpubuilder_x86_64.yml create mode 100644 dockerfiles/cpubuilder_ubuntu_jammy_ghr_x86_64.Dockerfile diff --git a/.github/workflows/publish_cpubuilder_x86_64.yml b/.github/workflows/publish_cpubuilder_x86_64.yml new file mode 100644 index 0000000..06d8855 --- /dev/null +++ b/.github/workflows/publish_cpubuilder_x86_64.yml @@ -0,0 +1,44 @@ +name: Publish cpubuilder x86_64 images +on: + workflow_dispatch: + push: + branches: ['main'] + paths: + - dockerfiles/cpubuilder*_ghr_x86_64.Dockerfile + - .github/workflows/publish_cpubuilder_x86_64.yml + +jobs: + build-cpubuilder-ubuntu-jammy-ghr: + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + IMAGE_NAME: nod-ai/cpubuilder_ubuntu_jammy_ghr_x86_64 + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + file: dockerfiles/cpubuilder_ubuntu_jammy_ghr_x86_64.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index eadefcf..1d6cd55 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # docker-build Utility repository for publishing docker images that we depend on. + +These images build and publish automatically by GH actions. To +build locally, use a command like: + +``` +docker buildx build --file dockerfiles/some.Dockerfile . +``` + +This will print a SHA image id, which you can run with: + +``` +sudo docker run --rm -it --entrypoint /bin/bash <> +``` diff --git a/dockerfiles/cpubuilder_ubuntu_jammy_ghr_x86_64.Dockerfile b/dockerfiles/cpubuilder_ubuntu_jammy_ghr_x86_64.Dockerfile new file mode 100644 index 0000000..1efe1be --- /dev/null +++ b/dockerfiles/cpubuilder_ubuntu_jammy_ghr_x86_64.Dockerfile @@ -0,0 +1,45 @@ +# GitHub Actions Runner with IREE build deps. +FROM docker.io/myoung34/github-runner:ubuntu-jammy + +# Apt packages. +RUN apt update && \ + apt install -y \ + wget python3.11 git unzip curl gnupg2 lsb-release && \ + update-alternatives --install /usr/local/bin/python python /usr/bin/python3.11 3 && \ + update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.11 3 && \ + apt install -y \ + ccache clang-14 lld-14 libssl-dev ninja-build libxml2-dev llvm-dev pkg-config \ + libcapstone-dev libtbb-dev libzstd-dev && \ + apt clean && rm -rf /var/lib/apt/lists/* + +# Python deps. +# It is expected the venvs get set up for real deployment needs. +# These are just basic deps for running automation. +RUN python -m pip --no-cache-dir install --upgrade pip && \ + python -m pip --no-cache-dir install \ + numpy==1.26.2 \ + requests==2.31.0 \ + setuptools==59.6.0 \ + PyYAML==5.4.1 + +# CMake. +# Version 3.23 has support for presets v4, needed for out of tree +# configurations. +RUN curl --silent --fail --show-error --location \ + "https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x86_64.sh" \ + --output /cmake-installer.sh && \ + bash /cmake-installer.sh --skip-license --prefix=/usr && \ + rm -f /cmake-installer.sh + +# Setup symlinks and alternatives. +RUN ln -s /usr/bin/lld-14 /usr/bin/lld && \ + ln -s /usr/bin/ld.lld-14 /usr/bin/ld.lld && \ + ln -s /usr/bin/clang-14 /usr/bin/clang && \ + ln -s /usr/bin/clang++-14 /usr/bin/clang++ + +# Environment. +ENV CC=clang +ENV CXX=clang++ + +# Switch back to the working directory upstream expects. +WORKDIR /actions-runner