Skip to content
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

Add Docker CI image. #3

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
python3-dev \
python3-venv \
python3-pip \
git \
git-lfs \
libhwloc-dev \
pandoc \
libtbb-dev \
libcapstone-dev \
pkg-config \
linux-tools-generic \
ninja-build \
wget \
libgtest-dev \
cmake \
ccache \
doxygen \
graphviz \
patchelf \
libyaml-cpp-dev \
libboost-all-dev

# Install clang 17
RUN wget https://apt.llvm.org/llvm.sh && \
chmod u+x llvm.sh && \
./llvm.sh 17 && \
apt install -y libc++-17-dev libc++abi-17-dev && \
ln -s /usr/bin/clang-17 /usr/bin/clang && \
ln -s /usr/bin/clang++-17 /usr/bin/clang++

# Install python packages
RUN pip install cmake

# Install Googletest
RUN git clone https://github.com/google/googletest.git -b release-1.12.1 && \
cd googletest && \
mkdir build && \
cd build && \
cmake .. -DBUILD_GMOCK=OFF && \
make && \
make install && \
cd ../.. && \
rm -rf googletest
65 changes: 65 additions & 0 deletions .github/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ARG GIT_SHA
ARG FROM_TAG=${GIT_SHA:-latest}

FROM ghcr.io/tenstorrent/tt-torch/tt-torch-base-ubuntu-22-04:${FROM_TAG} AS ci-build
SHELL ["/bin/bash", "-c"]

# Create a directory for the build and toolchain
ARG GIT_SHA
ENV PROJECT_NAME=tt-torch
ENV BUILD_DIR=/home/build
ENV TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain

RUN echo "Building $PROJECT_NAME at $GIT_SHA"

RUN mkdir -p $BUILD_DIR && \
mkdir -p $TTMLIR_TOOLCHAIN_DIR

# Clone tt-mlir
RUN git clone [email protected]:tenstorrent/tt-mlir.git $BUILD_DIR/$PROJECT_NAME && \
cd $BUILD_DIR/$PROJECT_NAME && \
git checkout $GIT_SHA

# Build the toolchain
WORKDIR $BUILD_DIR/$PROJECT_NAME
RUN source env/activate && \
cmake -B env/build env && \
cmake --build env/build

# Self-test

# Build project to test the container
RUN source env/activate && \
cmake -G Ninja \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DTTMLIR_ENABLE_RUNTIME=ON \
-DTTMLIR_ENABLE_RUNTIME_TESTS=ON \
-DTTMLIR_ENABLE_STABLEHLO=ON

RUN source env/activate && \
cmake --build build --config Release

RUN source env/activate && \
cmake --build build -- ttrt

# Run clang-tidy
RUN source env/activate && \
cmake --build build -- clang-tidy

# Run the tests
RUN source env/activate && \
cmake --build build -- check-ttmlir

# Final stage
FROM ghcr.io/tenstorrent/tt-torch/tt-torch-base-ubuntu-22-04:${FROM_TAG} AS ci

# Copy the TTMLIR_TOOLCHAIN_DIR from the previous stage
ENV TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain
RUN echo "Copying from ci-build stage $TTMLIR_TOOLCHAIN_DIR"
COPY --from=ci-build $TTMLIR_TOOLCHAIN_DIR $TTMLIR_TOOLCHAIN_DIR

RUN du -h --max-depth=2 $TTMLIR_TOOLCHAIN_DIR
90 changes: 90 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and Publish Docker Image

on:
workflow_dispatch:
workflow_call:

jobs:
build:

runs-on:
- in-service
- builder

env:
BASE_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-torch-base-ubuntu-22-04
CI_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-torch-ci-ubuntu-22-04

steps:

- name: Fix permissions
run: sudo chmod 777 -R $GITHUB_WORKSPACE

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build images

- name: Build and export base Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.base
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:${{ github.sha }}
- name: Build and export CI Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:${{ github.sha }}
- name: Build and export IRD Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.ird
push: true
build-args: |
GIT_SHA=${{ github.sha }}
FROM_IMAGE=ci
tags: |
${{ env.IRD_IMAGE_NAME}}:${{ github.sha }}
# Tag images as latest

- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.base
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:latest
- name: Build and push CI Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:latest