Skip to content

Commit

Permalink
Update Dockerfile and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lobantseff committed Oct 12, 2023
1 parent 8cf2afe commit 6fccac0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM condaforge/miniforge3:22.9.0-2
FROM condaforge/mambaforge
ENV PYTHONUNBUFFERED 1


Expand All @@ -14,7 +14,6 @@ RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
git \
git-lfs \
curl \
wget \
unzip \
Expand All @@ -26,25 +25,26 @@ RUN apt-get update \
openssh-server \
&& mkdir /var/run/sshd \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install \
&& echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config


# ----------------------------- Install dependencies ------------------------------
COPY environment.yaml /root/conda_environment.yaml
RUN conda env update -n base -f /root/conda_environment.yaml \
&& conda clean --all --yes \
&& conda init
RUN mamba config --set ssl_verify false \
&& mamba env update -n base -f /root/conda_environment.yaml \
&& mamba clean --all --yes \
&& mamba init

# xargs are used to make possible use pip install flags in requirements.txt
# see https://pip.pypa.io/en/stable/cli/pip_install
COPY requirements.txt /root/requirements.txt
RUN sed '/^#/d' /root/requirements.txt | xargs -L 1 pip install --no-cache-dir
RUN pip config --global set http.sslVerify false \
&& sed '/^#/d' /root/requirements.txt | xargs -L 1 pip install --no-cache-dir


# ------------------- Configure Jupyter and Tensorboard individually --------------------
COPY .jupyter_password set_jupyter_password.py /root/.jupyter/
RUN pip install jupyterlab ipywidgets tensorboard \
RUN pip install -U jupyterlab ipywidgets tensorboard \
&& python /root/.jupyter/set_jupyter_password.py /root

RUN echo "#!/bin/sh" > ~/init.sh \
Expand Down
2 changes: 1 addition & 1 deletion docker_build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ docker build -t $docker_image_name \
.


tmp_container_name=tmp_${docker_image_name}_$RANDOM
tmp_container_name=tmp_${docker_image_name%%:*}_$RANDOM
# ----- Install user packages from ./src to the container and submodules from ./libs ----
docker run -dt -v ${PWD}:/code --name $tmp_container_name --entrypoint="" $docker_image_name bash
for lib in $(ls ./libs)
Expand Down
27 changes: 21 additions & 6 deletions docker_start_interactive.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
set -e

# ------------- Read default image name from build output or manual input --------------
docker_image_name=$(cat .docker_image_name)
if [ -e .docker_image_name ]; then
docker_image_name=$(cat .docker_image_name)
else
docker_image_name=DOCKER_IMAGE_NAME
fi

read -r -p "Image [$docker_image_name]: " docker_image_name_input
docker_image_name=${docker_image_name_input:-$docker_image_name}

Expand All @@ -12,7 +17,12 @@ read -r -p "Container name [$container_name]: " container_name_input
container_name=${container_name_input:-$container_name}

# ----------------------------- Prompt for workspace folder -----------------------------
ws_dump=$(cat .ws_dir)
if [ -e .ws_dir ]; then
ws_dump=$(cat .ws_dir)
else
ws_dump=""
fi

read -r -p "Absolute path to the project workspace folder with data and experiment artifacts [$ws_dump]: " ws
ws=${ws:-$ws_dump}
if [ "$ws" ]
Expand All @@ -22,7 +32,12 @@ then
fi

# ---------------------------- Prompt for tensorboard folder ----------------------------
tb_dump=$(cat .tb_dir)
if [ -e .ws_dir ]; then
tb_dump=$(cat .tb_dir)
else
tb_dump=""
fi

tb=${tb_dump:="/ws/experiments"}
read -r -p "Relative path to the tensorboard logdir [$tb]: " tb
tb=${tb:-$tb_dump}
Expand All @@ -38,15 +53,15 @@ gpus=\"'device=str'\"
gpus=$(sed "s/str/$gpus_prompt/g" <<< $gpus)

# ---------------------------- Prompt for host Jupyter port -----------------------------
read -p "Jupyter port [8888]: " jupyter_port
read -p "Jupyter forwarded port [XXXX] -> container's 8888: " jupyter_port
jupyter_port=${jupyter_port:-8888}

# -------------------------- Prompt for host TensorBoard port ---------------------------
read -p "TensorBoard port [6006]: " tb_port
read -p "TensorBoard forwarded port [XXXX] -> container's 6006: " tb_port
tb_port=${tb_port:-6006}

# ------------------------------ Prompt for host SSH port -------------------------------
read -p "SSH port [22]: " ssh_port
read -p "SSH forwarded port [XXXX] -> container's 22: " ssh_port
ssh_port=${ssh_port:-22}

# -------------------------------- Start the container ----------------------------------
Expand Down
Empty file modified docker_start_noninteractive.sh
100644 → 100755
Empty file.

0 comments on commit 6fccac0

Please sign in to comment.