Skip to content
Merged
27 changes: 17 additions & 10 deletions notebooks/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Comment thread
fujikosu marked this conversation as resolved.
&& 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
1 change: 1 addition & 0 deletions notebooks/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": "../../",
Expand Down
35 changes: 21 additions & 14 deletions src/sample_cpu_project/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Comment thread
fujikosu marked this conversation as resolved.
&& 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


1 change: 1 addition & 0 deletions src/sample_cpu_project/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": "../../../",
Expand Down
36 changes: 21 additions & 15 deletions src/sample_pytorch_gpu_project/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Comment thread
fujikosu marked this conversation as resolved.
&& 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
Original file line number Diff line number Diff line change
@@ -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": "../../../",
Expand Down