Skip to content

Commit 9df7473

Browse files
committed
Clean up Dockerfile
1 parent 6abd4ed commit 9df7473

File tree

6 files changed

+53
-26
lines changed

6 files changed

+53
-26
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ on:
77
branches: [ "master" ]
88
workflow_dispatch:
99

10-
1110
concurrency:
12-
group: ${{ github.workflow }}-${{ github.ref }}
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1312
cancel-in-progress: true
1413

1514
jobs:

.github/workflows/container.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
branches: [ "master" ]
88
workflow_dispatch:
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
1014
env:
1115
IMAGE_NAME: pynucleus
1216
IMAGE_TAGS: latest ${{ github.sha }}

.github/workflows/documentation-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches: [ "master" ]
66
workflow_dispatch:
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
812
permissions:
913
contents: read
1014
id-token: write

Dockerfile

Lines changed: 29 additions & 24 deletions
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,33 @@ 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+
RUN \
45+
make prereq PIP_FLAGS=" --break-system-packages" \
46+
&& make prereq-extra PIP_FLAGS=" --break-system-packages"
4847

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
48+
# Build PyNucleus
49+
# RUN --mount=type=cache,target=/root/.ccache --mount=type=cache,target=/root/.cache/pip \
50+
RUN \
51+
make install PIP_INSTALL_FLAGS=" --break-system-packages" \
52+
&& find . -type f -name '*.c' -exec rm {} + \
53+
&& find . -type f -name '*.cpp' -exec rm {} + \
54+
&& rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build \
55+
&& ccache -s
5556

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

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
61+
# Set up greeting, settings
62+
RUN \
63+
echo '[ ! -z "$TERM" -a -r /pynucleus/README.container.rst ] && printf "\e[32m" && cat /pynucleus/README.container.rst && printf "\e[0m"' >> /etc/bash.bashrc \
64+
&& echo "alias ls='ls --color=auto -FN'" >> /etc/bash.bashrc \
65+
&& echo "set completion-ignore-case On" >> /etc/inputrc
6566

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

compose.yaml

Lines changed: 2 additions & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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)