diff --git a/notebooks/.devcontainer/Dockerfile b/notebooks/.devcontainer/Dockerfile index 4dc5812..20018ab 100644 --- a/notebooks/.devcontainer/Dockerfile +++ b/notebooks/.devcontainer/Dockerfile @@ -4,21 +4,28 @@ ARG USERNAME=devuser ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # Add sudo support - && apt-get update \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME + +# Add sudo support (using BuildKit cache mounts to speed up rebuilds) +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update \ && apt-get install -y sudo \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && rm -rf /var/lib/apt/lists/* + && chmod 0440 /etc/sudoers.d/$USERNAME USER $USERNAME -# make all python tools installed by pip accesible +# Make pip-installed tools accessible ENV PATH=$PATH:/home/$USERNAME/.local/bin -RUN pip install --no-cache-dir pip --upgrade + +# Install development tools (linters, formatters, test runners, etc.) +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip pip --upgrade COPY requirements-dev.txt . -RUN pip install --no-cache-dir -r requirements-dev.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r requirements-dev.txt -# install notebooks related depencencies +# Install notebooks related dependencies COPY notebooks/.devcontainer/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r requirements.txt diff --git a/notebooks/.devcontainer/devcontainer.json b/notebooks/.devcontainer/devcontainer.json index 8e45132..d73602e 100644 --- a/notebooks/.devcontainer/devcontainer.json +++ b/notebooks/.devcontainer/devcontainer.json @@ -1,4 +1,5 @@ { + "name": "DSToolkit Notebooks Dev Container", "build": { // use root directory as build context so that requirements-dev.txt is accessible during build "context": "../../", diff --git a/src/sample_cpu_project/.devcontainer/Dockerfile b/src/sample_cpu_project/.devcontainer/Dockerfile index e4bb9d4..dbb1830 100644 --- a/src/sample_cpu_project/.devcontainer/Dockerfile +++ b/src/sample_cpu_project/.devcontainer/Dockerfile @@ -4,29 +4,36 @@ ARG USERNAME=devuser ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # Add sudo support - && apt-get update \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME + +# Add sudo support (using BuildKit cache mounts to speed up rebuilds) +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update \ && apt-get install -y sudo \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && rm -rf /var/lib/apt/lists/* + && chmod 0440 /etc/sudoers.d/$USERNAME USER $USERNAME -# make all python tools installed by pip accesible -ENV PATH=$PATH:/home/devuser/.local/bin +# Make pip-installed tools accessible +ENV PATH=$PATH:/home/$USERNAME/.local/bin -RUN pip install --no-cache-dir pip --upgrade +# Install Python packages (using BuildKit cache mounts for faster rebuilds) +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip pip --upgrade COPY src/sample_cpu_project/.devcontainer/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r requirements.txt -# install common module related pacakages -COPY src/common/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +# Install common module related packages +COPY src/common/requirements.txt common-requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r common-requirements.txt -# install python tools +# Install development tools (linters, formatters, test runners, etc.) COPY requirements-dev.txt . -RUN pip install --no-cache-dir -r requirements-dev.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r requirements-dev.txt diff --git a/src/sample_cpu_project/.devcontainer/devcontainer.json b/src/sample_cpu_project/.devcontainer/devcontainer.json index b6d537b..839d3dc 100644 --- a/src/sample_cpu_project/.devcontainer/devcontainer.json +++ b/src/sample_cpu_project/.devcontainer/devcontainer.json @@ -1,4 +1,5 @@ { + "name": "Sample CPU Project Dev Container", "build": { // use root directory as build context so that requirements-dev.txt is accessible during build "context": "../../../", diff --git a/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile b/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile index 83326a2..b76a8b0 100644 --- a/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile +++ b/src/sample_pytorch_gpu_project/.devcontainer/Dockerfile @@ -6,30 +6,36 @@ ARG USERNAME=devuser ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # Add sudo support - && apt-get update \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME + +# Add sudo support (using BuildKit cache mounts to speed up rebuilds) +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update \ && apt-get install -y sudo \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && rm -rf /var/lib/apt/lists/* + && chmod 0440 /etc/sudoers.d/$USERNAME USER $USERNAME - -# make all python tools installed by pip accesible +# Make pip-installed tools accessible ENV PATH=$PATH:/home/$USERNAME/.local/bin -RUN pip install pip --upgrade +# Install Python packages (using BuildKit cache mounts for faster rebuilds) +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip pip --upgrade COPY src/sample_pytorch_gpu_project/.devcontainer/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r requirements.txt -# install common module related pacakages -COPY src/common/requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +# Install common module related packages +COPY src/common/requirements.txt common-requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r common-requirements.txt -# install python tools +# Install development tools (linters, formatters, test runners, etc.) COPY requirements-dev.txt . -RUN pip install --no-cache-dir -r requirements-dev.txt +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --cache-dir=/root/.cache/pip -r requirements-dev.txt -RUN az extension add --name ml +RUN az extension add --name ml --yes diff --git a/src/sample_pytorch_gpu_project/.devcontainer/devcontainer.json b/src/sample_pytorch_gpu_project/.devcontainer/devcontainer.json index f151bda..725a88f 100644 --- a/src/sample_pytorch_gpu_project/.devcontainer/devcontainer.json +++ b/src/sample_pytorch_gpu_project/.devcontainer/devcontainer.json @@ -1,4 +1,5 @@ { + "name": "Sample PyTorch GPU Project Dev Container", "build": { // use root directory as build context so that requirements-dev.txt is accessible during build "context": "../../../",