Skip to content

Commit

Permalink
docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
broskoTT committed Sep 24, 2024
1 parent 9c142d9 commit d1af049
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 4 deletions.
28 changes: 28 additions & 0 deletions .github/ubuntu-20.04.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

# Install build and runtime deps
RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
cmake \
ninja-build \
git \
libhwloc-dev \
libgtest-dev \
libyaml-cpp-dev \
libboost-all-dev \
wget

# 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 clang-format
RUN apt install -y clang-format-17 && \
ln -s /usr/bin/clang-format-17 /usr/bin/clang-format
28 changes: 28 additions & 0 deletions .github/ubuntu-22.04.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Install build and runtime deps
RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
cmake \
ninja-build \
git \
libhwloc-dev \
libgtest-dev \
libyaml-cpp-dev \
libboost-all-dev \
wget

# 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 clang-format
RUN apt install -y clang-format-17 && \
ln -s /usr/bin/clang-format-17 /usr/bin/clang-format
71 changes: 71 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Publish Docker Image

on:
workflow_dispatch:
workflow_call:
push:

jobs:
build:

runs-on:
- in-service
- builder

strategy:
fail-fast: false
matrix:
build: [
{name: ubuntu-22.04},
{name: ubuntu-20.04},
]

env:
CI_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-umd-ci-${{ matrix.build.name }}

name: Building docker image ${{ env.CI_IMAGE_NAME }}
runs-on: ${{ matrix.build.name }}

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 image

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

- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
context: .github
file: .github/${{ matrix.build.name }}.Dockerfile
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:latest
6 changes: 4 additions & 2 deletions .github/workflows/build-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
inputs:
arch:
required: true
description: 'The architecture to build for'
type: choice
options:
- grayskull
Expand All @@ -18,7 +19,6 @@ on:

jobs:
build:
name: Build umd_device for ${{ inputs.arch }}

timeout-minutes: 30
strategy:
Expand All @@ -28,14 +28,16 @@ jobs:
{runs-on: ubuntu-22.04},
{runs-on: ubuntu-20.04},
]

name: Build umd_device for ${{ inputs.arch }} architecture on machine ${{ matrix.build.runs-on }}
runs-on: ${{ matrix.build.runs-on }}
container:
image: ghcr.io/${{ github.repository }}/tt-metalium/${{ matrix.build.runs-on }}:latest
options: --user root

env:
ARCH_NAME: ${{ inputs.arch }}

steps:
- uses: actions/checkout@v4
with:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ on:
- grayskull
- wormhole_b0
- blackhole

env:
BUILD_OUTPUT_DIR: ${{ github.workspace }}/build
INSTALL_OUTPUT_DIR: ${{ github.workspace }}/install
BUILD_ARTEFACT_NAME: umd_tests

jobs:
build:
Expand All @@ -30,6 +32,8 @@ jobs:
{name: ubuntu-22.04},
{name: ubuntu-20.04},
]

name: Build ${{ env.BUILD_ARTEFACT_NAME }} for ${{ inputs.arch }} architecture on machine ${{ matrix.build.runs-on }}
runs-on: ${{ matrix.build.name }}
container:
image: ghcr.io/${{ github.repository }}/tt-metalium/${{ matrix.build.name }}:latest
Expand Down Expand Up @@ -60,13 +64,13 @@ jobs:
run: |
echo "Compiling the code..."
cmake -B ${{ env.BUILD_OUTPUT_DIR }} -G Ninja
cmake --build ${{ env.BUILD_OUTPUT_DIR }} --target umd_tests
cmake --build ${{ env.BUILD_OUTPUT_DIR }} --target ${{ env.BUILD_ARTEFACT_NAME }}
echo "Compile complete."
- name: Install UMD
run: |
echo "Installing the code..."
cmake --install ${{ env.BUILD_OUTPUT_DIR }} --component umd_device --prefix ${{ env.INSTALL_OUTPUT_DIR }}
cmake --install ${{ env.BUILD_OUTPUT_DIR }} --component ${{ env.BUILD_ARTEFACT_NAME }} --prefix ${{ env.INSTALL_OUTPUT_DIR }}
echo "Install complete."
# This is needed to preserve file permissions
Expand Down

0 comments on commit d1af049

Please sign in to comment.