Skip to content

Commit 38263e2

Browse files
committed
Update Build Matrix
1 parent 4e9841a commit 38263e2

6 files changed

Lines changed: 43 additions & 31 deletions

File tree

.github/workflows/cd-docker-build-push.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ jobs:
99
build-and-push:
1010
runs-on: ubuntu-latest
1111
strategy:
12-
# If any matrix job fails, cancel all others immediately.
1312
fail-fast: true
1413
matrix:
15-
# Defines the different configurations to build.
16-
# This will generate 16 parallel jobs (2 * 2 * 2 * 2).
1714
dockerfile: ["Dockerfile.cuda", "Dockerfile.common"]
1815
install_llvm: [true, false]
19-
install_rust: [true, false]
2016
install_torch: [true, false]
2117

2218
steps:
@@ -32,27 +28,24 @@ jobs:
3228
swap-storage: true
3329

3430
- name: Checkout repository
35-
uses: actions/checkout@v4 # Using the latest version
31+
uses: actions/checkout@v4
3632

3733
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v3 # Using the latest version
34+
uses: docker/setup-buildx-action@v3
3935

4036
- name: Login to Docker Hub
41-
uses: docker/login-action@v3 # Using the latest version
37+
uses: docker/login-action@v3
4238
with:
4339
username: ${{ secrets.DOCKERHUB_USERNAME }}
4440
password: ${{ secrets.DOCKERHUB_TOKEN }}
4541

4642
- name: Build Docker image
4743
env:
48-
# Set environment variables for the build script from the matrix
4944
INSTALL_LLVM: ${{ matrix.install_llvm }}
50-
INSTALL_RUST: ${{ matrix.install_rust }}
5145
INSTALL_TORCH: ${{ matrix.install_torch }}
52-
# Pass the correct Dockerfile name from the matrix to the build script
53-
run: bash ./scripts/build.sh "${{ matrix.dockerfile }}"
46+
run: |
47+
bash ./scripts/build.sh "${{ matrix.dockerfile }}"
48+
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
5449
55-
- name: Push Docker image(s)
56-
# This assumes push.sh can discover and push the image(s) created
57-
# in the previous step without explicit arguments.
58-
run: bash ./scripts/push.sh
50+
- name: Push Docker image
51+
run: bash ./scripts/push.sh "${{ env.IMAGE_NAME }}"

Dockerfile.common

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ ARG DEBIAN_FRONTEND=noninteractive
77
ENV LANGUAGE=en_US.UTF-8
88
ENV LANG=en_US.UTF-8
99

10+
ARG INSTALL_LLVM
11+
ARG INSTALL_RUST
12+
ARG INSTALL_TORCH
1013
ARG LLVM_VERSION
1114
ARG IMAGE_VERSION
1215
ARG TORCH_VERSION
@@ -36,7 +39,7 @@ RUN wget -O /tmp/kitware-archive.sh \
3639
apt-get update && apt-get install -y cmake
3740

3841
# LLVM
39-
RUN if [[ "${INSTALL_LLVM}" == "ture" ]]; then \
42+
RUN if [[ "${INSTALL_LLVM}" == "true" ]]; then \
4043
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
4144
tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
4245
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble main" | \
@@ -56,12 +59,12 @@ RUN if [[ "${INSTALL_LLVM}" == "ture" ]]; then \
5659
ln -s /usr/bin/clang-tidy-${LLVM_VERSION} /usr/bin/clang-tidy && \
5760
ln -s /usr/bin/clang-format-${LLVM_VERSION} /usr/bin/clang-format && \
5861
ln -s /usr/bin/lldb-${LLVM_VERSION} /usr/bin/lldb \
62+
else \
63+
echo "Skip installing LLVM" \
5964
fi
6065

6166
# Rust
62-
RUN if [[ "${INSTALL_RULST}" == "true" ]]; then \
63-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
64-
fi
67+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6568

6669
# Config files
6770
COPY data/.vimrc data/.inputrc data/.bashrc data/.tmux.conf /root/
@@ -75,10 +78,12 @@ RUN wget -O /tmp/miniconda3.sh \
7578
conda upgrade libstdcxx-ng -c conda-forge -y && \
7679
pip3 install nvitop --no-cache-dir && \
7780
if [[ "${INSTALL_TORCH}" == "true" ]]; then \
78-
TORCH_CU_VER=$(echo $CUDA_VERSION | cut -d'.' -f1,2 | tr -d '.') && \
81+
TORCH_CU_VER=$(echo $CUDA_VERSION | cut -d'.' -f1,2 | tr -d '.') && \
7982
pip3 install torch==${TORCH_VERSION} torchvision torchaudio \
80-
--index-url "https://download.pytorch.org/whl/cu${TORCH_CU_VER}" \
83+
https://download.pytorch.org/whl/cpu \
8184
--no-cache-dir \
85+
else \
86+
echo "Skip installing torch" \
8287
fi
8388

8489
# Some final steps

Dockerfile.cuda

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ ARG DEBIAN_FRONTEND=noninteractive
77
ENV LANGUAGE=en_US.UTF-8
88
ENV LANG=en_US.UTF-8
99

10+
ARG INSTALL_LLVM
11+
ARG INSTALL_RUST
12+
ARG INSTALL_TORCH
1013
ARG LLVM_VERSION
1114
ARG IMAGE_VERSION
1215
ARG TORCH_VERSION
@@ -36,7 +39,7 @@ RUN wget -O /tmp/kitware-archive.sh \
3639
apt-get update && apt-get install -y cmake
3740

3841
# LLVM
39-
RUN if [[ "${INSTALL_LLVM}" == "ture" ]]; then \
42+
RUN if [[ "${INSTALL_LLVM}" == "true" ]]; then \
4043
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
4144
tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
4245
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble main" | \
@@ -56,12 +59,12 @@ RUN if [[ "${INSTALL_LLVM}" == "ture" ]]; then \
5659
ln -s /usr/bin/clang-tidy-${LLVM_VERSION} /usr/bin/clang-tidy && \
5760
ln -s /usr/bin/clang-format-${LLVM_VERSION} /usr/bin/clang-format && \
5861
ln -s /usr/bin/lldb-${LLVM_VERSION} /usr/bin/lldb \
62+
else \
63+
echo "Skip installing LLVM" \
5964
fi
6065

6166
# Rust
62-
RUN if [[ "${INSTALL_RULST}" == "true" ]]; then \
63-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
64-
fi
67+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6568

6669
# Config files
6770
COPY data/.vimrc data/.inputrc data/.bashrc data/.tmux.conf /root/
@@ -79,6 +82,8 @@ RUN wget -O /tmp/miniconda3.sh \
7982
pip3 install torch==${TORCH_VERSION} torchvision torchaudio \
8083
--index-url "https://download.pytorch.org/whl/cu${TORCH_CU_VER}" \
8184
--no-cache-dir \
85+
else \
86+
echo "Skip installing torch" \
8287
fi
8388

8489
# Some final steps

scripts/.image-configs.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
IMAGE_VERSION=2.1.3
1+
IMAGE_VERSION=2.2.0
22
TORCH_VERSION=2.7.1
33
CUDA_VERSION=12.8.0
44
UBUNTU_VERSION=24.04
55
LLVM_VERSION=21
6-
IMAGE_TAG=v${IMAGE_VERSION}-torch${TORCH_VERSION}-cuda${CUDA_VERSION}-ubuntu${UBUNTU_VERSION}
7-
IMAGE_NAME=jamesnulliu/deeplearning:${IMAGE_TAG}
6+
IMAGE_TAG="v${IMAGE_VERSION}"

scripts/build.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
set -e
22

3+
DOCKER_FILE=$1
4+
35
source ./scripts/.image-configs.sh
46

7+
if [[ "${DOCKER_FILE}" == *.cuda ]]; then IMAGE_TAG="${IMAGE_TAG}-cuda${CUDA_VERSION}"; fi
8+
if [[ "${INSTALL_TORCH}" == "true" ]]; then IMAGE_TAG="${IMAGE_TAG}-torch${TORCH_VERSION}"; fi
9+
if [[ "${INSTALL_LLVM}" == "true" ]]; then IMAGE_TAG="${IMAGE_TAG}-llvm${LLVM_VERSION}"; fi
10+
11+
export IMAGE_NAME=jamesnulliu/deeplearning:${IMAGE_TAG}
12+
513
docker build \
6-
-f Dockerfile \
7-
--build-arg IMAGE_VERSION=$IMAGE_VERSION \
14+
-f $DOCKER_FILE \
15+
--build-arg INSTALL_LLVM=$INSTALL_LLVM \
16+
--build-arg INSTALL_TORCH=$INSTALL_TORCH \
17+
--build-arg IMAGE_VERSION=$IMAGE_VERSION \
818
--build-arg TORCH_VERSION=$TORCH_VERSION \
919
--build-arg CUDA_VERSION=$CUDA_VERSION \
1020
--build-arg UBUNTU_VERSION=$UBUNTU_VERSION \

scripts/push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
source ./scripts/.image-configs.sh
22

3-
docker image push $IMAGE_NAME
3+
docker image push $1

0 commit comments

Comments
 (0)