Skip to content

Commit e1859d6

Browse files
committed
Update Build Matrix
1 parent 4e9841a commit e1859d6

5 files changed

Lines changed: 34 additions & 22 deletions

File tree

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ 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]
1916
install_rust: [true, false]
@@ -32,27 +29,25 @@ jobs:
3229
swap-storage: true
3330

3431
- name: Checkout repository
35-
uses: actions/checkout@v4 # Using the latest version
32+
uses: actions/checkout@v4
3633

3734
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v3 # Using the latest version
35+
uses: docker/setup-buildx-action@v3
3936

4037
- name: Login to Docker Hub
41-
uses: docker/login-action@v3 # Using the latest version
38+
uses: docker/login-action@v3
4239
with:
4340
username: ${{ secrets.DOCKERHUB_USERNAME }}
4441
password: ${{ secrets.DOCKERHUB_TOKEN }}
4542

4643
- name: Build Docker image
4744
env:
48-
# Set environment variables for the build script from the matrix
4945
INSTALL_LLVM: ${{ matrix.install_llvm }}
5046
INSTALL_RUST: ${{ matrix.install_rust }}
5147
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 }}"
48+
run: |
49+
bash ./scripts/build.sh "${{ matrix.dockerfile }}"
50+
echo "IMAGE_NAME=$(bash ./scripts/get_image_name.sh)" >> $GITHUB_ENV
5451
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
52+
- name: Push Docker image
53+
run: bash ./scripts/push.sh "${{ env.IMAGE_NAME }}"

Dockerfile.common

Lines changed: 6 additions & 3 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
@@ -59,7 +62,7 @@ RUN if [[ "${INSTALL_LLVM}" == "ture" ]]; then \
5962
fi
6063

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

@@ -75,9 +78,9 @@ 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 \
8285
fi
8386

Dockerfile.cuda

Lines changed: 4 additions & 1 deletion
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
@@ -59,7 +62,7 @@ RUN if [[ "${INSTALL_LLVM}" == "ture" ]]; then \
5962
fi
6063

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

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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
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+
if [[ "${INSTALL_RUST}" == "true" ]]; then IMAGE_TAG="${IMAGE_TAG}-rust"; fi
11+
12+
export IMAGE_NAME=jamesnulliu/deeplearning:${IMAGE_TAG}
13+
514
docker build \
6-
-f Dockerfile \
7-
--build-arg IMAGE_VERSION=$IMAGE_VERSION \
15+
-f $DOCKER_FILE \
16+
--build-arg INSTALL_LLVM=$INSTALL_LLVM \
17+
--build-arg INSTALL_RUST=$INSTALL_RUST \
18+
--build-arg INSTALL_TORCH=$INSTALL_TORCH \
19+
--build-arg IMAGE_VERSION=$IMAGE_VERSION \
820
--build-arg TORCH_VERSION=$TORCH_VERSION \
921
--build-arg CUDA_VERSION=$CUDA_VERSION \
1022
--build-arg UBUNTU_VERSION=$UBUNTU_VERSION \

0 commit comments

Comments
 (0)