Skip to content

Commit

Permalink
Use n150 for Docker CI image.
Browse files Browse the repository at this point in the history
  • Loading branch information
uazizTT committed Oct 29, 2024
2 parents 46675ae + 9aec852 commit 1a4da93
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 0 deletions.
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
37 changes: 37 additions & 0 deletions .github/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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

# Copy the project from host, cloned in build-image.yml
COPY . $BUILD_DIR/$PROJECT_NAME

# Build the toolchain
WORKDIR $BUILD_DIR/$PROJECT_NAME
RUN cmake -B toolchain -DTOOLCHAIN=ON third_party/ && \
cd third_party/tt-mlir/src/tt-mlir/ && \
source env/activate && \
cmake -B env/build env && \
cmake --build env/build

# 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
78 changes: 78 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

name: Build and Publish Docker Image

on:
workflow_dispatch:
workflow_call:

jobs:
build:

runs-on:
- n150

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
with:
submodules: recursive
lfs: true

- 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:
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:
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:${{ github.sha }}
# Tag images as latest

- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
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:
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:latest

0 comments on commit 1a4da93

Please sign in to comment.