Skip to content

Commit

Permalink
wip: build ascent docker example (#1347)
Browse files Browse the repository at this point in the history
* add venv to ubuntu base

* docs fix

* add simplified docker example for ascent + jupyter (still wip)

* resolve confusion from stray file

* docker recipe adjustments
  • Loading branch information
cyrush authored Aug 2, 2024
1 parent 6f877f1 commit fce0b2a
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 161 deletions.

This file was deleted.

5 changes: 4 additions & 1 deletion scripts/build_ascent/build_ascent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,10 @@ if [ ! -d ${mfem_src_dir} ]; then
tar ${tar_extra_args} -xzf ${mfem_tarball} -C ${source_dir}
fi


#
# Note: MFEM MPI requires Hypre and Metis
# -DMFEM_USE_MPI=${enable_mpi} \

echo "**** Configuring MFEM ${mfem_version}"
cmake -S ${mfem_src_dir} -B ${mfem_build_dir} ${cmake_compiler_settings} \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${enable_verbose}\
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/docker/alpinedav_ubuntu_22.04_devel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN apt-get update && apt-get -y install \
python3 \
python3-dev \
python-is-python3 \
python3.10-venv \
clang \
llvm \
perl \
Expand Down
8 changes: 4 additions & 4 deletions src/docs/sphinx/Tutorial_CloverLeaf_Demos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,16 @@ First you will need to install the ``ascent_jupyter_bridge`` python module locat

.. code::
pip install -r requirements.txt
pip install .
python3 -m pip install -r requirements.txt
python3 -m ipykernel install
If you are at a site that does SSL interception and can not configure your SSL certificates to avoid pip SSL errors, you can use the following:

.. code::
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org .
python3 -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt
python3 -m ipykernel install
We will once again use the Cloverleaf3D Ascent integration, so make sure you are in the ``examples/ascent/proxies/cloverleaf3d`` directory of your Ascent install.
Expand Down
142 changes: 142 additions & 0 deletions src/examples/docker/ubuntu-build-ascent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
# other details. No copyright assignment is required to contribute to Ascent.

#################################################
# all in one build of ascent container w/ jupyter
#################################################

FROM ubuntu:22.04

#####################
# base deps
#####################
# add sudo to base ubuntu container
# so we can install additional packages as
# non-root, but admin default user on azure pipelines
RUN apt-get update && apt-get -y install sudo
# tzdata install wants to ask questions, so handled as sep case
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
# install std packages
RUN apt-get update && apt-get -y install \
binutils \
cmake \
gcc \
g++ \
gfortran \
python3 \
python3-dev \
python-is-python3 \
python3.10-venv \
clang \
llvm \
perl \
git \
git-lfs \
curl \
wget \
tar \
unzip \
file \
build-essential \
libncurses-dev \
libssl-dev \
libblas-dev \
liblapack-dev \
liblapacke-dev \
zlib1g-dev \
libgdbm-dev \
libreadline-dev \
libsqlite3-dev \
libbz2-dev \
mpich \
libmpich-dev \
openssh-server \
vim

# nodejs is needed by jupyterlab for widgets
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs
RUN rm -rf /var/lib/apt/lists/*

#####################
# ascent build
#####################

# obtain a copy of ascent source from host env and extract
COPY ascent.docker.src.tar.gz /
RUN tar -xzf ascent.docker.src.tar.gz

# change perms of source scripts
RUN chmod -R a+rwX /ascent/
RUN chmod +x /ascent/scripts/build_ascent/build_ascent.sh

# copy docker specific build script in
COPY docker_build_ascent.sh /
RUN ./docker_build_ascent.sh

# ascent is installed at /install/ascent-checkout, symlink to /ascent/install
RUN ln -s /install/ascent-checkout /ascent/install
# symlink proxies for easy access next to jupyter notebooks
RUN ln -s /ascent/install/examples/ascent/proxies/ /ascent/install/examples/ascent/tutorial/ascent_intro/notebooks/
# symlink notebooks to shorter root path
RUN ln -s /ascent/install/examples/ascent/tutorial/ascent_intro/notebooks/ /tutorial_notebooks

# change perms of build results
RUN chmod a+rwX /*.sh
RUN chmod -R a+rwX /install/
# setup perms for tutorial cleanup scripts
RUN chmod 777 /ascent/install/examples/ascent/tutorial/ascent_intro/*/cleanup.sh

# add env setup for login
RUN cp /ascent_docker_setup_env.sh /etc/profile.d/ascent_docker_setup_env.sh

# force the use of a login shell
RUN /bin/echo -e '#!/bin/bash -l\n' \
'exec "$@"\n' \
> /etc/entrypoint.sh && \
chmod a+x /etc/entrypoint.sh

# set main
ENTRYPOINT ["/etc/entrypoint.sh"]

#####################
# jupyter lab setup
#####################

# add our `user` with password `docker`
RUN useradd -ms /bin/bash -G sudo user && echo "user:docker" | chpasswd
# allow sudo w/o password
RUN echo "user ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
chmod 0440 /etc/sudoers.d/user

# run the rest as `user`
USER user
WORKDIR /home/user

# setup ssh keys for passwordless ssh to localhost
RUN mkdir -p ~/.ssh
RUN ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""
RUN cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
RUN chmod 0600 ~/.ssh/authorized_keys

# setup jupyter password, the password is:
# learn
RUN mkdir /home/user/.jupyter/
RUN echo "c.NotebookApp.password = 'sha1:9777986fd066:283f673e1a311e2d5ef58c174eaebf3e1cb536dd'" > /home/user/.jupyter/jupyter_notebook_config.py

# set bash as default jupyter shell
RUN echo "c.NotebookApp.terminado_settings = { 'shell_command': ['/bin/bash'] }" >> /home/user/.jupyter/jupyter_notebook_config.py

# gen script that allows us to easily run jupyter lab
RUN cp /ascent_docker_setup_env.sh /home/user/ascent_docker_run_jupyterlab.sh
RUN echo "jupyter lab --ip=\"0.0.0.0\" --no-browser" >> /home/user/ascent_docker_run_jupyterlab.sh

# make sure helpers are executable
RUN sudo chmod 777 /home/user/ascent_docker_run_jupyterlab.sh

# open port 8888, for use by jupyter notebook http server
EXPOSE 8888

# default setup -- launch jupyter lab
CMD sudo service ssh start && cd /tutorial_notebooks/ && /home/user/ascent_docker_run_jupyterlab.sh
15 changes: 15 additions & 0 deletions src/examples/docker/ubuntu-build-ascent/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
# other details. No copyright assignment is required to contribute to Ascent.

export REPO_NAME="ascent"
export TAG_ARCH=`uname -m`
export TAG_BASE=alpinedav/ascent:ascent-ubuntu-22.04-develop-${TAG_ARCH}

date

python3 ../../../../scripts/docker_build_and_tag.py ${REPO_NAME} ${TAG_ARCH} ${TAG_BASE}

date

38 changes: 38 additions & 0 deletions src/examples/docker/ubuntu-build-ascent/docker_build_ascent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -ev

env enable_python=ON \
enable_mpi=ON \
enable_FORTRAN=ON \
enable_openmp=ON \
build_pyvenv=true \
/ascent/scripts/build_ascent/build_ascent.sh

# install extra python modules
/install/python-venv/bin/python3 -m pip install \
--trusted-host pypi.org --trusted-host files.pythonhosted.org \
bash_kernel \
jupyter \
jupyterlab \
ipykernel \
pylint \
ipywidgets \
ipympl \
matplotlib \
pyyaml \
cinemasci \
scipy \
scikit-learn \
h5py \
llnl-hatchet

cd /install/ascent-checkout/share/ascent/ascent_jupyter_bridge/ && \
/install/python-venv/bin/python3 -m ipykernel install

conduit_py_path=`ls -d /install/conduit-*/python-modules`
ascent_py_path=`ls -d /install/ascent-*/python-modules`
vtkm_lib_path=`ls -d /install/vtk-m-*/lib`
echo "export PATH=/install/python-venv/bin/:$PATH" >> /ascent_docker_setup_env.sh
echo "export PYTHONPATH=${conduit_py_path}:${ascent_py_path}" >> /ascent_docker_setup_env.sh
echo "export LD_LIBRARY_PATH=${vtkm_lib_path}" >> /ascent_docker_setup_env.sh

0 comments on commit fce0b2a

Please sign in to comment.