Skip to content

Clean up Dockerfile #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ on:
branches: [ "master" ]
workflow_dispatch:


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches: [ "master" ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: pynucleus
IMAGE_TAGS: latest ${{ github.sha }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/documentation-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [ "master" ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read
id-token: write
Expand Down
53 changes: 29 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ LABEL maintainer Christian Glusa

# 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 \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
gcc g++ make gfortran \
libssl-dev ca-certificates \
ccache \
git less nano \
libopenblas0-serial \
libmetis-dev libparmetis-dev \
Expand All @@ -37,30 +39,33 @@ WORKDIR /pynucleus

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 && \
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
# Install dependencies
# RUN --mount=type=cache,target=/root/.ccache --mount=type=cache,target=/root/.cache/pip \
RUN \
make prereq PIP_FLAGS=" --break-system-packages" \
&& make prereq-extra PIP_FLAGS=" --break-system-packages"

# 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 "alias ls='ls --color=auto -FN'" >> /etc/bash.bashrc && \
echo "set completion-ignore-case On" >> /etc/inputrc
# Build PyNucleus
# RUN --mount=type=cache,target=/root/.ccache --mount=type=cache,target=/root/.cache/pip \
RUN \
make install PIP_INSTALL_FLAGS=" --break-system-packages" \
&& 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 \
&& ccache -s

WORKDIR /root
# Generate documentation and examples
RUN make docs \
&& rm examples/test.hdf5

# Copy examples and drivers to user home, launch Jupyter notebook server
ENTRYPOINT mkdir -p /root/examples && \
mkdir -p /root/drivers && \
cp -r --update=none /pynucleus/examples/* /root/examples && \
cp -r --update=none /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
# Set up greeting, settings
RUN \
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

# Set up entrypoint with jupyter notebook
COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]
WORKDIR /root
EXPOSE 8889
2 changes: 2 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ services:
# Expose a Jupyter notebook server from the container
- 8889:8889
network_mode: host
user: root
hostname: pynucleus-container
command: bash

tests:
image: ghcr.io/sandialabs/pynucleus:latest
Expand Down
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

mkdir -p ~/examples
mkdir -p ~/drivers
cp -r --update=none /pynucleus/examples/* ~/examples
cp -r --update=none /pynucleus/drivers/* ~/drivers

jupyter notebook --port=8889 --no-browser --allow-root --ip=0.0.0.0 \
--NotebookApp.token='' --NotebookApp.password='' \
--notebook-dir=/root > /dev/null 2>&1 &

exec "$@"