Skip to content

Commit 0097072

Browse files
committed
simplify container
1 parent 4f14280 commit 0097072

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

.github/workflows/container.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ jobs:
4141
tags: ${{ env.IMAGE_TAGS }}
4242
containerfiles: |
4343
./Dockerfile
44+
build-args: |
45+
PYNUCLEUS_BUILD_PARALLELISM=4
4446
4547
- name: Run tests
4648
run: |
47-
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/
49+
podman run \
50+
-e MPIEXEC_FLAGS="--allow-run-as-root --oversubscribe" \
51+
--workdir /pynucleus \
52+
--rm \
53+
--entrypoint='["python3", "-m", "pytest", "--junit-xml", "test-results.xml"]' \
54+
${{ steps.build_image.outputs.image }}:${{ github.sha }}
4855
4956
- name: Push To GHCR
5057
if: github.event_name == 'push'

.github/workflows/documentation-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/cache/restore@v4
2727
with:
2828
path: /home/runner/.cache/ccache
29-
key: ccache
29+
key: ccache-documentation-ci
3030

3131
- uses: actions/setup-python@v5
3232
with:
@@ -57,7 +57,7 @@ jobs:
5757
uses: actions/cache/save@v4
5858
with:
5959
path: /home/runner/.cache/ccache
60-
key: ccache
60+
key: ccache-documentation-ci
6161

6262
- name: Build documentation
6363
run: |

Dockerfile

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,31 @@
1-
# VERSION: 0.1
1+
# VERSION: 1.0
22
# DESCRIPTION: Dockerized PyNucleus build
33
# AUTHOR: Christian Glusa
44

55
# Base docker image
66
FROM debian:testing
77
LABEL maintainer Christian Glusa
88

9-
ENV LANG en_US.UTF-8
10-
119
# install packages needed for build
1210
RUN sed -i 's/Components: main/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources \
1311
&& apt-get update && \
1412
DEBIAN_FRONTEND=noninteractive apt-get install -y \
15-
locales \
16-
autoconf automake gcc g++ make gfortran wget zlib1g-dev libffi-dev \
17-
tk-dev \
18-
libssl-dev ca-certificates cmake \
19-
git less \
20-
libboost-dev \
13+
gcc g++ make gfortran \
14+
libssl-dev ca-certificates \
15+
git less nano \
16+
libmetis-dev libparmetis-dev \
2117
hdf5-tools \
2218
libsuitesparse-dev \
2319
libarpack2-dev \
2420
mpi-default-bin mpi-default-dev \
25-
python3 python3-dev python-is-python3 python3-pip python3-mpi4py cython3 python3-numpy python3-scipy python3-matplotlib python3-tk python3-venv \
26-
libmetis-dev libparmetis-dev \
27-
texlive texlive-extra-utils texlive-latex-extra ttf-staypuft dvipng cm-super \
28-
jupyter-notebook \
29-
emacs-nox vim \
21+
python3 python3-dev python-is-python3 python3-pip \
22+
python3-numpy python3-scipy python3-matplotlib python3-mpi4py cython3 python3-yaml python3-h5py python3-tk jupyter-notebook \
3023
--no-install-recommends \
31-
&& rm -rf /var/lib/apt/lists/* \
32-
&& sed -i -e "s/# $LANG.*/$LANG UTF-8/" /etc/locale.gen \
33-
&& dpkg-reconfigure --frontend=noninteractive locales \
34-
&& update-locale LANG=$LANG
24+
&& rm -rf /var/lib/apt/lists/*
3525

3626
# allow running MPI as root in the container
3727
# bind MPI ranks to hwthreads
38-
ENV LANG=en_US.UTF-8 \
39-
LANGUAGE=en_US:en \
40-
LC_ALL=en_US.UTF-8 \
41-
VIRTUAL_ENV=/pynucleus/venv \
42-
PATH="/pynucleus/venv/bin:$PATH" \
43-
OMPI_MCA_hwloc_base_binding_policy=hwthread \
28+
ENV OMPI_MCA_hwloc_base_binding_policy=hwthread \
4429
MPIEXEC_FLAGS=--allow-run-as-root \
4530
OMPI_ALLOW_RUN_AS_ROOT=1 \
4631
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
@@ -49,14 +34,32 @@ COPY . /pynucleus
4934

5035
WORKDIR /pynucleus
5136

52-
RUN python3 -m venv $VIRTUAL_ENV && \
53-
make prereq PIP_FLAGS=--no-cache-dir && \
54-
make prereq-extra PIP_FLAGS=--no-cache-dir && \
55-
make install && \
37+
ARG PYNUCLEUS_BUILD_PARALLELISM=1
38+
39+
# Build PyNucleus
40+
RUN make prereq PIP_FLAGS="--no-cache-dir --break-system-packages" && \
41+
make prereq-extra PIP_FLAGS="--no-cache-dir --break-system-packages" && \
42+
make install PIP_INSTALL_FLAGS="--no-cache-dir --break-system-packages" && \
5643
make docs && \
57-
python -m pip install --no-cache-dir ipykernel && \
58-
rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build && \
44+
find . -type f -name '*.c' -exec rm {} + && \
45+
find . -type f -name '*.cpp' -exec rm {} + && \
46+
rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build
47+
48+
# Set up Jupyter notebooks, greeting, some bash things
49+
RUN python -m pip install --no-cache-dir --break-system-packages ipykernel && \
5950
python -m ipykernel install --name=PyNucleus && \
60-
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc
51+
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc && \
52+
echo "alias ls='ls --color=auto -FN'" >> /etc/bash.bashrc && \
53+
echo "set completion-ignore-case On" >> /etc/inputrc
6154

6255
WORKDIR /root
56+
57+
# Copy examples and drivers to user home, launch Jupyter notebook server
58+
ENTRYPOINT mkdir -p /root/examples && \
59+
mkdir -p /root/drivers && \
60+
cp -r --no-clobber /pynucleus/examples/* /root/examples && \
61+
cp -r --no-clobber /pynucleus/drivers/* /root/drivers && \
62+
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 & \
63+
/bin/bash
64+
65+
EXPOSE 8889

compose.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,13 @@ services:
1515
- HTTP_PROXY=${HTTP_PROXY}
1616
- HTTPS_PROXY=${HTTPS_PROXY}
1717
volumes:
18-
# The current directory on host gets mapped to /pynucleus/root in the container
18+
# The current directory on host gets mapped to /root in the container
1919
- $PWD:/root
2020
# map files to container to allow GUI windows
2121
- /tmp/.X11-unix:/tmp/.X11-unix
2222
- $XAUTHORITY:/root/.Xauthority
2323
ports:
2424
# Expose a Jupyter notebook server from the container
25-
- 8889:8888
25+
- 8889:8889
2626
network_mode: host
2727
hostname: pynucleus-container
28-
command: >
29-
sh -c "
30-
mkdir -p /root/examples &&
31-
mkdir -p /root/drivers &&
32-
cp -r --update=none /pynucleus/examples/* /root/examples &&
33-
cp -r --update=none /pynucleus/drivers/* /root/drivers &&
34-
if [ ! -f /root/.bashrc ]; then echo \"alias ls='ls --color=auto -FN'\" >> /root/.bashrc ; fi &&
35-
if [ ! -f /root/.inputrc ]; then echo \"set completion-ignore-case On\" >> /root/.inputrc ; fi &&
36-
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 &
37-
/bin/bash"

0 commit comments

Comments
 (0)