Skip to content

Commit

Permalink
Attempt to build container
Browse files Browse the repository at this point in the history
  • Loading branch information
cgcgcg committed Dec 9, 2023
1 parent fc2f019 commit a7ea3a8
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 46 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
workflow_dispatch:

jobs:
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Container

on:
# push:
# branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

env:
IMAGE_NAME: pynucleus
IMAGE_TAGS: latest ${{ github.sha }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}

jobs:

container:
runs-on: ubuntu-latest
timeout-minutes: 300

steps:
- name: Check out
if: always()
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
ignore: 'DL3008,DL3013'

- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
containerfiles: |
./Dockerfile
- name: Run image
run: |
podman run -e MPIEXEC_FLAGS="--allow-run-as-root --oversubscribe" --rm ${{ steps.build_image.outputs.image }}:${{ github.sha }} python3 -m pytest --junit-xml=test-results.xml tests/
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
id: push
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
extra-args: |
--disable-content-trust
- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: Documentation

on:
push:
branches: [ "master" ]
# push:
# branches: [ "master" ]
workflow_dispatch:

permissions:
Expand Down
52 changes: 24 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ LABEL maintainer Christian Glusa

ENV LANG C.UTF-8

# based on recommendations from
# https://docs.nersc.gov/development/shifter/how-to-use/

# add contrib and non-free debian repos
RUN sed -i "s#deb http://deb.debian.org/debian testing main#deb http://deb.debian.org/debian testing main contrib non-free#g" /etc/apt/sources.list

# install packages needed for build
RUN apt-get update && \
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 \
autoconf automake gcc g++ make gfortran wget zlib1g-dev libffi-dev \
tk-dev \
Expand All @@ -25,30 +20,31 @@ RUN apt-get update && \
hdf5-tools \
libsuitesparse-dev \
libarpack2-dev \
libmkl-avx2 libmkl-dev \
mpi-default-bin mpi-default-dev \
python3 python3-dev python3-pip python3-mpi4py cython3 python3-numpy python3-scipy python3-matplotlib python3-tk \
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 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV LD_LIBRARY_PATH /usr/local/lib

RUN echo "alias ls='ls --color=auto -FN'" >> /root/.bashrc

RUN /sbin/ldconfig


# copy code to container and build
# we copy only the packages over, not any run scripts

COPY PyNucleus /home/pynucleus-build/PyNucleus
COPY packageTools /home/pynucleus-build/packageTools
COPY base /home/pynucleus-build/base
COPY metisCy /home/pynucleus-build/metisCy
COPY fem /home/pynucleus-build/fem
COPY multilevelSolver /home/pynucleus-build/multilevelSolver
COPY nl /home/pynucleus-build/nl
COPY setup.py setup.cfg versioneer.py MANIFEST.in Makefile README.rst LICENSE /home/pynucleus-build/
RUN cd /home/pynucleus-build && make
COPY . /pynucleus
ENV VIRTUAL_ENV=/pynucleus/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /pynucleus
RUN make prereq && \
make prereq-extra && \
make install && \
python -m pip install --no-cache-dir ipykernel && \
rm -rf build packageTools/build base/build metisCy/build fem/build multilevelSolver/build nl/build

RUN echo "alias ls='ls --color=auto -FN'" >> /root/.bashrc \
&& echo 'set completion-ignore-case On' >> /root/.inputrc

# allow running MPI as root in the container
# bind MPI ranks to hwthreads
ENV OMPI_MCA_hwloc_base_binding_policy=hwthread \
MPIEXEC_FLAGS=--allow-run-as-root

RUN python -m ipykernel install --name=PyNucleus
19 changes: 7 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,23 @@ docker:
# rm -rf docker-build

docker-linux:
# enable access to xserver (so that we can see some plots)
xhost +
# run the container
docker run -it \
-v $(XAUTHORITY):/.Xauthority -e XAUTHORITY=/.Xauthority \
-v "/tmp/.X11-unix:/tmp/.X11-unix:rw" -e DISPLAY=$(DISPLAY) \
podman run -it \
-v $(XAUTHORITY):/root/.Xauthority \
-v "/tmp/.X11-unix:/tmp/.X11-unix:rw" \
-e DISPLAY=$(DISPLAY) \
--network "host" \
-e HTTP_PROXY=$(HTTP_PROXY) \
-e HTTPS_PROXY=$(HTTPS_PROXY) \
-e http_proxy=$(http_proxy) \
-e https_proxy=$(https_proxy) \
-v $(PWD):/home/pynucleus \
-w "/home/pynucleus/" \
dockerized-pynucleus
# disable access to xserver
xhost -

localhost/pynucleus-test

docker-mac:
docker run -it \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) \
--network host \
-e HTTP_PROXY=$(HTTP_PROXY) \
-e HTTPS_PROXY=$(HTTPS_PROXY) \
-e http_proxy=$(http_proxy) \
Expand All @@ -167,8 +164,6 @@ docker-mac:
-w "/home/pynucleus/" \
dockerized-pynucleus



prereq:
$(PYTHON) -m pip install $(PIP_FLAGS) $(PIP_INSTALL_FLAGS) wheel Cython cython numpy scipy matplotlib pyyaml h5py pybind11 MeshPy tabulate modepy mpi4py pyamg meshio
$(PYTHON) -m pip install $(PIP_FLAGS) $(PIP_INSTALL_FLAGS) scikit-sparse
Expand Down
44 changes: 44 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 3

services:

# Launch with:
# docker compose run --profile interactive pynucleus
pynucleus:
image: ghcr.io/sandialabs/pynucleus:latest
build: .
environment:
# host display server
- DISPLAY=${DISPLAY}
# expose host proxies
- http_proxy=${http_proxy}
- https_proxy=${https_proxy}
- HTTP_PROXY=${HTTP_PROXY}
- HTTPS_PROXY=${HTTPS_PROXY}
volumes:
# The current directory on host gets mapped to /pynucleus/user in the container
- $PWD:/pynucleus/user
# map files to container to allow GUI windows
- /tmp/.X11-unix:/tmp/.X11-unix
- $XAUTHORITY:/root/.Xauthority
network_mode: host

# Launch with:
# docker compose up
# Then open localhost:8888 in your browser
pynucleus-jupyter:
image: ghcr.io/sandialabs/pynucleus:latest
build: .
command: jupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token='' --NotebookApp.password='' --notebook-dir=/pynucleus/user
environment:
# expose host proxies
- http_proxy=${http_proxy}
- https_proxy=${https_proxy}
- HTTP_PROXY=${HTTP_PROXY}
- HTTPS_PROXY=${HTTPS_PROXY}
volumes:
# The current directory on host gets mapped to /pynucleus/user in the container
- $PWD/notebooks:/pynucleus/user
ports:
# Expose a Jupyter notebook server from the container
- 8889:8888

0 comments on commit a7ea3a8

Please sign in to comment.