Skip to content

Commit 59ae467

Browse files
committed
Clean up Dockerfile
1 parent 6abd4ed commit 59ae467

File tree

3 files changed

+42
-24
lines changed

3 files changed

+42
-24
lines changed

Dockerfile

+27-24
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ LABEL maintainer Christian Glusa
88

99
# install packages needed for build
1010
RUN sed -i 's/Components: main/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources \
11-
&& apt-get update && \
12-
DEBIAN_FRONTEND=noninteractive apt-get install -y \
11+
&& apt-get update \
12+
&& DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y \
13+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
1314
gcc g++ make gfortran \
1415
libssl-dev ca-certificates \
16+
ccache \
1517
git less nano \
1618
libopenblas0-serial \
1719
libmetis-dev libparmetis-dev \
@@ -37,30 +39,31 @@ WORKDIR /pynucleus
3739

3840
ARG PYNUCLEUS_BUILD_PARALLELISM=1
3941

40-
# Build PyNucleus
41-
RUN make prereq PIP_FLAGS="--no-cache-dir --break-system-packages" && \
42-
make prereq-extra PIP_FLAGS="--no-cache-dir --break-system-packages" && \
43-
make install PIP_INSTALL_FLAGS="--no-cache-dir --break-system-packages" && \
44-
make docs && \
45-
find . -type f -name '*.c' -exec rm {} + && \
46-
find . -type f -name '*.cpp' -exec rm {} + && \
47-
rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build
42+
# Install dependencies
43+
RUN --mount=type=cache,target=/root/.ccache --mount=type=cache,target=/root/.cache/pip \
44+
make prereq PIP_FLAGS=" --break-system-packages" \
45+
&& make prereq-extra PIP_FLAGS=" --break-system-packages"
4846

49-
# Set up Jupyter notebooks, greeting, some bash things
50-
RUN python -m pip install --no-cache-dir --break-system-packages ipykernel && \
51-
python -m ipykernel install --name=PyNucleus && \
52-
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc && \
53-
echo "alias ls='ls --color=auto -FN'" >> /etc/bash.bashrc && \
54-
echo "set completion-ignore-case On" >> /etc/inputrc
47+
# Build PyNucleus
48+
RUN --mount=type=cache,target=/root/.ccache --mount=type=cache,target=/root/.cache/pip \
49+
make install PIP_INSTALL_FLAGS=" --break-system-packages" \
50+
&& find . -type f -name '*.c' -exec rm {} + \
51+
&& find . -type f -name '*.cpp' -exec rm {} + \
52+
&& rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build \
53+
&& ccache -s
5554

56-
WORKDIR /root
55+
# Generate documentation and examples
56+
RUN make docs \
57+
&& rm examples/test.hdf5
5758

58-
# Copy examples and drivers to user home, launch Jupyter notebook server
59-
ENTRYPOINT mkdir -p /root/examples && \
60-
mkdir -p /root/drivers && \
61-
cp -r --update=none /pynucleus/examples/* /root/examples && \
62-
cp -r --update=none /pynucleus/drivers/* /root/drivers && \
63-
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 & \
64-
/bin/bash
59+
# Set up greeting, settings
60+
RUN \
61+
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc \
62+
&& echo "alias ls='ls --color=auto -FN'" >> /etc/bash.bashrc \
63+
&& echo "set completion-ignore-case On" >> /etc/inputrc
6564

65+
# Set up entrypoint with jupyter notebook
66+
COPY entrypoint.sh /usr/local/bin/
67+
ENTRYPOINT ["entrypoint.sh"]
68+
WORKDIR /root
6669
EXPOSE 8889

compose.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ services:
2424
# Expose a Jupyter notebook server from the container
2525
- 8889:8889
2626
network_mode: host
27+
user: root
2728
hostname: pynucleus-container
29+
command: bash
2830

2931
tests:
3032
image: ghcr.io/sandialabs/pynucleus:latest

entrypoint.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
mkdir -p ~/examples
5+
mkdir -p ~/drivers
6+
cp -r --update=none /pynucleus/examples/* ~/examples
7+
cp -r --update=none /pynucleus/drivers/* ~/drivers
8+
9+
jupyter notebook --port=8889 --no-browser --allow-root --ip=0.0.0.0 \
10+
--NotebookApp.token='' --NotebookApp.password='' \
11+
--notebook-dir=/root > /dev/null 2>&1 &
12+
13+
exec "$@"

0 commit comments

Comments
 (0)