Skip to content

Commit ea7f217

Browse files
authored
Set WORKDIR in base Docker images (#3358)
Use /dstack/run (rwx for all) as a default working dir. In addition, dstack:dstack user with passwordless sudo added, but not (yet) used as a default user. Part-of: #3124
1 parent 168c631 commit ea7f217

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.github/workflows/docker.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ jobs:
6565
password: ${{ secrets.DOCKERHUB_TOKEN }}
6666
- name: Set up QEMU
6767
uses: docker/setup-qemu-action@v3
68+
- name: Free up some space
69+
run: |
70+
df -h /
71+
du -hs /usr/share/dotnet
72+
rm -rf /usr/share/dotnet
73+
df -h /
6874
- name: Build and upload to DockerHub
6975
run: |
70-
if [ "${{ matrix.flavor }}" = "base" ]; then
76+
if [ "${{ matrix.flavor }}" = "base" ]; then
7177
FILE="base/Dockerfile"
7278
elif [ "${{ matrix.flavor }}" = "devel" ]; then
7379
FILE="base/Dockerfile"

docker/base/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ RUN apt-get update \
7777
&& rm -rf /var/lib/apt/lists/* \
7878
&& echo "${NCCL_HOME}/lib" >> /etc/ld.so.conf.d/nccl.conf \
7979
&& ldconfig
80+
81+
WORKDIR /dstack/run

docker/base/Dockerfile.common

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ RUN export DEBIAN_FRONTEND=noninteractive \
2424
&& dpkg-reconfigure --frontend noninteractive tzdata \
2525
&& apt-get install -y bzip2 ca-certificates curl build-essential git libglib2.0-0 libsm6 libxext6 libxrender1 mercurial openssh-server subversion wget \
2626
libibverbs1 ibverbs-providers ibverbs-utils libibverbs-dev infiniband-diags \
27-
&& rm -rf /var/lib/apt/lists/* \
2827
&& sed -i "s/.*PasswordAuthentication.*/PasswordAuthentication no/g" /etc/ssh/sshd_config \
2928
&& mkdir /run/sshd \
3029
&& mkdir ~/.ssh && chmod 700 ~/.ssh && touch ~/.ssh/authorized_keys \
3130
&& chmod 600 ~/.ssh/authorized_keys \
32-
&& rm /etc/ssh/ssh_host_*
31+
&& rm /etc/ssh/ssh_host_* \
32+
# User
33+
&& apt-get install -y sudo \
34+
&& groupadd -g 1000 dstack \
35+
&& useradd -u 1000 -g 1000 -G sudo -s /bin/bash -m dstack \
36+
&& echo 'dstack ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/dstack \
37+
# Default working dir
38+
&& mkdir -p /dstack/run \
39+
&& chmod a+rwx /dstack/run \
40+
# Cleanup
41+
&& rm -rf /var/lib/apt/lists/*
3342

3443
RUN curl -LsSf https://astral.sh/uv/install.sh | INSTALLER_NO_MODIFY_PATH=1 sh \
3544
&& uv python install --preview --default

docker/base/efa/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ RUN cd /opt \
7474
MPI_HOME=${OPEN_MPI_PATH} \
7575
CUDA_HOME=${CUDA_HOME} \
7676
NCCL_HOME=${NCCL_HOME}
77+
78+
WORKDIR /dstack/run

0 commit comments

Comments
 (0)