Skip to content

Commit

Permalink
simplify container
Browse files Browse the repository at this point in the history
  • Loading branch information
cgcgcg committed Mar 2, 2024
1 parent 4f14280 commit 0097072
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,17 @@ jobs:
tags: ${{ env.IMAGE_TAGS }}
containerfiles: |
./Dockerfile
build-args: |
PYNUCLEUS_BUILD_PARALLELISM=4
- name: Run tests
run: |
podman run -e MPIEXEC_FLAGS="--allow-run-as-root --oversubscribe" --workdir /pynucleus --rm ${{ steps.build_image.outputs.image }}:${{ github.sha }} python3 -m pytest --junit-xml=test-results.xml tests/
podman run \
-e MPIEXEC_FLAGS="--allow-run-as-root --oversubscribe" \
--workdir /pynucleus \
--rm \
--entrypoint='["python3", "-m", "pytest", "--junit-xml", "test-results.xml"]' \
${{ steps.build_image.outputs.image }}:${{ github.sha }}
- name: Push To GHCR
if: github.event_name == 'push'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/documentation-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: /home/runner/.cache/ccache
key: ccache
key: ccache-documentation-ci

- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: /home/runner/.cache/ccache
key: ccache
key: ccache-documentation-ci

- name: Build documentation
run: |
Expand Down
65 changes: 34 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,31 @@
# VERSION: 0.1
# VERSION: 1.0
# DESCRIPTION: Dockerized PyNucleus build
# AUTHOR: Christian Glusa

# Base docker image
FROM debian:testing
LABEL maintainer Christian Glusa

ENV LANG en_US.UTF-8

# install packages needed for build
RUN sed -i 's/Components: main/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources \
&& apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
locales \
autoconf automake gcc g++ make gfortran wget zlib1g-dev libffi-dev \
tk-dev \
libssl-dev ca-certificates cmake \
git less \
libboost-dev \
gcc g++ make gfortran \
libssl-dev ca-certificates \
git less nano \
libmetis-dev libparmetis-dev \
hdf5-tools \
libsuitesparse-dev \
libarpack2-dev \
mpi-default-bin mpi-default-dev \
python3 python3-dev python-is-python3 python3-pip python3-mpi4py cython3 python3-numpy python3-scipy python3-matplotlib python3-tk python3-venv \
libmetis-dev libparmetis-dev \
texlive texlive-extra-utils texlive-latex-extra ttf-staypuft dvipng cm-super \
jupyter-notebook \
emacs-nox vim \
python3 python3-dev python-is-python3 python3-pip \
python3-numpy python3-scipy python3-matplotlib python3-mpi4py cython3 python3-yaml python3-h5py python3-tk jupyter-notebook \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& sed -i -e "s/# $LANG.*/$LANG UTF-8/" /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& update-locale LANG=$LANG
&& rm -rf /var/lib/apt/lists/*

# allow running MPI as root in the container
# bind MPI ranks to hwthreads
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
VIRTUAL_ENV=/pynucleus/venv \
PATH="/pynucleus/venv/bin:$PATH" \
OMPI_MCA_hwloc_base_binding_policy=hwthread \
ENV OMPI_MCA_hwloc_base_binding_policy=hwthread \
MPIEXEC_FLAGS=--allow-run-as-root \
OMPI_ALLOW_RUN_AS_ROOT=1 \
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
Expand All @@ -49,14 +34,32 @@ COPY . /pynucleus

WORKDIR /pynucleus

RUN python3 -m venv $VIRTUAL_ENV && \
make prereq PIP_FLAGS=--no-cache-dir && \
make prereq-extra PIP_FLAGS=--no-cache-dir && \
make install && \
ARG PYNUCLEUS_BUILD_PARALLELISM=1

# Build PyNucleus
RUN make prereq PIP_FLAGS="--no-cache-dir --break-system-packages" && \
make prereq-extra PIP_FLAGS="--no-cache-dir --break-system-packages" && \
make install PIP_INSTALL_FLAGS="--no-cache-dir --break-system-packages" && \
make docs && \
python -m pip install --no-cache-dir ipykernel && \
rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build && \
find . -type f -name '*.c' -exec rm {} + && \
find . -type f -name '*.cpp' -exec rm {} + && \
rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build

# Set up Jupyter notebooks, greeting, some bash things
RUN python -m pip install --no-cache-dir --break-system-packages ipykernel && \
python -m ipykernel install --name=PyNucleus && \
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc && \
echo "alias ls='ls --color=auto -FN'" >> /etc/bash.bashrc && \
echo "set completion-ignore-case On" >> /etc/inputrc

WORKDIR /root

# Copy examples and drivers to user home, launch Jupyter notebook server
ENTRYPOINT mkdir -p /root/examples && \
mkdir -p /root/drivers && \
cp -r --no-clobber /pynucleus/examples/* /root/examples && \
cp -r --no-clobber /pynucleus/drivers/* /root/drivers && \
jupyter notebook --port=8889 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token='' --NotebookApp.password='' --notebook-dir=/root/ --KernelSpecManager.ensure_native_kernel=False --KernelSpecManager.allowed_kernelspecs=pynucleus > /dev/null 2>&1 & \
/bin/bash

EXPOSE 8889
14 changes: 2 additions & 12 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,13 @@ services:
- HTTP_PROXY=${HTTP_PROXY}
- HTTPS_PROXY=${HTTPS_PROXY}
volumes:
# The current directory on host gets mapped to /pynucleus/root in the container
# The current directory on host gets mapped to /root in the container
- $PWD:/root
# map files to container to allow GUI windows
- /tmp/.X11-unix:/tmp/.X11-unix
- $XAUTHORITY:/root/.Xauthority
ports:
# Expose a Jupyter notebook server from the container
- 8889:8888
- 8889:8889
network_mode: host
hostname: pynucleus-container
command: >
sh -c "
mkdir -p /root/examples &&
mkdir -p /root/drivers &&
cp -r --update=none /pynucleus/examples/* /root/examples &&
cp -r --update=none /pynucleus/drivers/* /root/drivers &&
if [ ! -f /root/.bashrc ]; then echo \"alias ls='ls --color=auto -FN'\" >> /root/.bashrc ; fi &&
if [ ! -f /root/.inputrc ]; then echo \"set completion-ignore-case On\" >> /root/.inputrc ; fi &&
jupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token='' --NotebookApp.password='' --notebook-dir=/root/ --KernelSpecManager.ensure_native_kernel=False --KernelSpecManager.allowed_kernelspecs=pynucleus > /dev/null 2>&1 &
/bin/bash"

0 comments on commit 0097072

Please sign in to comment.