Skip to content

Commit 57ab13d

Browse files
Experimental: Build default Docker images for both Ubuntu versions 20.04 and 22.04
1 parent 035eced commit 57ab13d

8 files changed

Lines changed: 23 additions & 15 deletions

File tree

.github/workflows/docker.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
strategy:
5353
matrix:
5454
flavor: ["base", "devel", "devel-efa"]
55+
ubuntu_version: ["20", "22"]
5556
steps:
5657
- name: Checkout repository
5758
uses: actions/checkout@v4
@@ -75,7 +76,7 @@ jobs:
7576
fi
7677
docker buildx build \
7778
--platform linux/amd64 \
78-
--tag dstackai/${{ env.BUILD_DOCKER_REPO }}:${{ inputs.image_version }}-${{ matrix.flavor }} \
79+
--tag dstackai/${{ env.BUILD_DOCKER_REPO }}:${{ inputs.image_version }}-${{ matrix.flavor }}-ubuntu${{ matrix.ubuntu_version }}.04 \
7980
--build-arg FLAVOR=${{ matrix.flavor }} \
8081
--provenance=false \
8182
--push \

docker/base/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# syntax = edrevo/dockerfile-plus
2+
ARG UBUNTU_VERSION
23

34
# Build stage
4-
FROM nvidia/cuda:12.1.1-base-ubuntu20.04 AS builder
5+
FROM nvidia/cuda:12.1.1-base-ubuntu${UBUNTU_VERSION}.04 AS builder
56

67
ENV NCCL_HOME=/opt/nccl
78
ENV CUDA_HOME=/usr/local/cuda
@@ -10,7 +11,7 @@ ENV OPEN_MPI_PATH=/usr/lib/x86_64-linux-gnu/openmpi
1011
# Prerequisites
1112

1213
RUN export DEBIAN_FRONTEND=noninteractive \
13-
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub \
14+
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}04/x86_64/3bf863cc.pub \
1415
&& apt-get update --fix-missing \
1516
&& apt-get upgrade -y \
1617
&& ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime \

docker/base/Dockerfile.common

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM nvidia/cuda:12.1.1-base-ubuntu20.04
1+
ARG UBUNTU_VERSION
2+
3+
FROM nvidia/cuda:12.1.1-base-ubuntu${UBUNTU_VERSION}.04
24

35
ARG _UV_HOME="/opt/uv"
46

@@ -9,7 +11,7 @@ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
911
ENV PATH="${UV_INSTALL_DIR}:${PATH}"
1012

1113
RUN export DEBIAN_FRONTEND=noninteractive \
12-
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub \
14+
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}04/x86_64/3bf863cc.pub \
1315
&& apt-get update --fix-missing \
1416
&& apt-get upgrade -y \
1517
&& ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime \

src/dstack/_internal/server/background/tasks/process_running_jobs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,9 @@ def _patch_base_image_for_aws_efa(
999999
if not image_name.startswith(f"{settings.DSTACK_BASE_IMAGE}:"):
10001000
return image_name
10011001

1002-
if image_name.endswith("-base"):
1003-
return image_name[:-5] + "-devel-efa"
1004-
elif image_name.endswith("-devel"):
1005-
return image_name[:-6] + "-devel-efa"
1002+
if image_name.endswith(f"-base-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"):
1003+
return image_name[:-17] + f"-devel-efa-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
1004+
elif image_name.endswith(f"-devel-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"):
1005+
return image_name[:-18] + f"-devel-efa-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
10061006

10071007
return image_name

src/dstack/_internal/server/services/jobs/configurators/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_default_image(nvcc: bool = False) -> str:
5858
Args:
5959
nvcc: If True, returns 'devel' variant, otherwise 'base'.
6060
"""
61-
return f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}-{'devel' if nvcc else 'base'}"
61+
return f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}-{'devel' if nvcc else 'base'}-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
6262

6363

6464
class JobConfigurator(ABC):

src/dstack/_internal/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
DSTACK_BASE_IMAGE = os.getenv("DSTACK_BASE_IMAGE", "dstackai/base")
1616
DSTACK_BASE_IMAGE_VERSION = os.getenv("DSTACK_BASE_IMAGE_VERSION", version.base_image)
17+
DSTACK_BASE_IMAGE_UBUNTU_VERSION = os.getenv(
18+
"DSTACK_BASE_IMAGE_UBUNTU_VERSION", version.base_image_ubuntu_version
19+
)
1720

1821

1922
class FeatureFlags:

src/dstack/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__version__ = "0.0.0"
22
__is_release__ = False
33
base_image = "0.10"
4+
base_image_ubuntu_version = "20.04"

src/tests/_internal/server/background/tasks/test_process_running_jobs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,11 @@ def _call_patch_base_image_for_aws_efa(
931931
],
932932
)
933933
def test_patch_aws_efa_instance_with_suffix(self, suffix: str, instance_type: str):
934-
image_name = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}{suffix}"
934+
image_name = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}{suffix}-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
935935
result = self._call_patch_base_image_for_aws_efa(
936936
image_name, BackendType.AWS, instance_type
937937
)
938-
expected = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}-devel-efa"
938+
expected = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}-devel-efa-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
939939
assert result == expected
940940

941941
@pytest.mark.parametrize("suffix", ["-base", "-devel"])
@@ -954,11 +954,11 @@ def test_patch_aws_efa_instance_with_suffix(self, suffix: str, instance_type: st
954954
],
955955
)
956956
def test_patch_all_efa_instance_types(self, instance_type: str, suffix: str):
957-
image_name = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}{suffix}"
957+
image_name = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}{suffix}-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
958958
result = self._call_patch_base_image_for_aws_efa(
959959
image_name, BackendType.AWS, instance_type
960960
)
961-
expected = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}-devel-efa"
961+
expected = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}-devel-efa-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
962962
assert result == expected
963963

964964
@pytest.mark.parametrize("suffix", ["-base", "-devel"])
@@ -978,7 +978,7 @@ def test_patch_all_efa_instance_types(self, instance_type: str, suffix: str):
978978
def test_no_patch_non_aws_backends(
979979
self, backend: BackendType, suffix: str, instance_type: str
980980
):
981-
image_name = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}{suffix}"
981+
image_name = f"{settings.DSTACK_BASE_IMAGE}:{settings.DSTACK_BASE_IMAGE_VERSION}{suffix}-ubuntu{settings.DSTACK_BASE_IMAGE_UBUNTU_VERSION}"
982982
result = self._call_patch_base_image_for_aws_efa(image_name, backend, instance_type)
983983
assert result == image_name
984984

0 commit comments

Comments
 (0)