diff --git a/README.rst b/README.rst index aebea89..67e4b5a 100644 --- a/README.rst +++ b/README.rst @@ -110,3 +110,8 @@ Run the application assuming the same layout as previously described cd ./moose/examples/ex08_materials make peacock-trame -I ./ex08.i + +Docker image +----------------------------------------------------------- + +Alternatively you can use the docker image. Just head to the `docker folder/ `_ diff --git a/docker/Dockerfile.moosepv b/docker/Dockerfile.moosepv new file mode 100644 index 0000000..31b8d5b --- /dev/null +++ b/docker/Dockerfile.moosepv @@ -0,0 +1,29 @@ +FROM idaholab/moose:2025.05.30-1a66aba + +WORKDIR /opt + +SHELL ["/bin/bash", "-ce"] + +# install paraview +RUN wget --quiet -O ParaView-6.0.0-MPI-Linux-Python3.12-x86_64.tar.gz "https://www.paraview.org/files/v6.0/ParaView-6.0.0-MPI-Linux-Python3.12-x86_64.tar.gz" && \ + tar xf "ParaView-6.0.0-MPI-Linux-Python3.12-x86_64.tar.gz" && \ + mv ParaView-6.0.0-MPI-Linux-Python3.12-x86_64/ paraview/ && \ + rm ParaView-6.0.0-MPI-Linux-Python3.12-x86_64.tar.gz + +ENV PVPYTHONPATH=/opt/paraview/bin/pvpython + +ENV NVIDIA_DRIVER_CAPABILITIES=all +ENV NVIDIA_VISIBLE_DEVICES=all + +ENV MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA + +# install packages for both NVIDIA EGL and mesa llvmpipe runtimes +RUN dnf install -qy libglvnd-opengl libglvnd-egl mesa-libGL mesa-dri-drivers + +COPY ./add_moose_examples.bash /work/add_moose_examples.bash +RUN /work/add_moose_examples.bash + +# build the porous_flow module +RUN cd /work/moose/modules/porous_flow && source /environment && make -j $(( $(nproc) - 2)) + +ENTRYPOINT ["/opt/paraview/bin/pvpython"] diff --git a/docker/Dockerfile.peacock b/docker/Dockerfile.peacock new file mode 100644 index 0000000..250d4df --- /dev/null +++ b/docker/Dockerfile.peacock @@ -0,0 +1,30 @@ +FROM node:20-bookworm AS js_assets_builder + +WORKDIR /work + +RUN git clone https://github.com/idaholab/moose-language-support.git && \ + cd moose-language-support && npm install --no-audit && \ + npm run esbuild + +ENV NODE_OPTIONS=--openssl-legacy-provider + +RUN git clone https://github.com/Kitware/peacock.git && \ + cd peacock/vue-components && npm i --no-audit && npm run build && \ + cd /work/peacock/lang-server && npm i --no-audit && npm run build + +FROM moosepv:latest + +WORKDIR /work + +COPY --from=js_assets_builder /work/moose-language-support/out /work/moose-language-support/out +COPY --from=js_assets_builder /work/peacock /work/peacock + +COPY ./run_peacock.bash /work/run_peacock.bash + +RUN /opt/miniforge3/bin/python3.12 -m venv venv && ./venv/bin/python -m pip install --upgrade pip && \ + ./venv/bin/python -m pip install vtk && ./venv/bin/python -m pip install /work/peacock + +ENV PYTHON_EXECUTABLE=/work/venv/bin/python + +ENTRYPOINT ["/work/run_peacock.bash"] +CMD ["-I", "/work/moose/examples/ex08_materials/ex08.i"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..887aa8f --- /dev/null +++ b/docker/README.md @@ -0,0 +1,45 @@ +# Peacock docker image + +## Build +```bash +docker build -f Dockerfile.moosepv . -t moosepv:latest +docker build -f Dockerfile.peacock . -t peacock:latest +``` + + +## Basic usage +```bash +# run the image with default entrypoint and builtin peacock +# ParaView OpenGL renderer will be llvmpipe +docker run -it --rm -p 8080:8080 peacock:latest + +# same but if you have a NVIDIA GPU you want to use +docker run --privileged --runtime=nvidia --gpus all -it --rm -p 8080:8080 peacock:latest + +# run with custom peacock input and executable, here porous_flow +docker run -it --rm -p 8080:8080 peacock:latest -I /work/moose/modules/porous_flow/examples/flow_through_fractured_media/diffusion.i -E /work/moose/modules/porous_flow/porous_flow-opt +``` + +## Advanced usage +```bash +# run the image with an interactive bash shell for more control +docker run -it --rm -p 8080:8080 --entrypoint /bin/bash peacock:latest + +# map your local data into the container +# example: use host input file with container executable +# the -u flag is important so that the output files are written back to the host with correct permissions +docker run -it --rm -p 8080:8080 -u $UID:$GID -v /path/to/moose/examples/ex08_materials:/work/user_data peacock:latest -I /work/user_data/ex08.i -E /work/moose/examples/ex08_materials/ex08-opt + +# by overriding the container entrypoint, you can do much more than just running peacock +# example, getting porous flow options as JSON +docker run -it --rm --entrypoint /work/moose/modules/porous_flow/porous_flow-opt peacock:latest -options_left 0 --json > porous_flow_params.json + +# for peacock developers: mount your local peacock +cd /path/to/your/local/peacock +docker run -it --rm -p 8080:8080 --entrypoint /bin/bash -v $PWD:/work/peacock peacock:latest +# then, pip install peacock in editable mode +> $PYTHON_EXECUTABLE -m pip install -e /work/peacock +# you're now free to modify your host peacock and run it inside the container +# just make sure the vue-components and lang-server are built on the host +> /work/run_peacock.bash -I /work/moose/examples/ex08_materials/ex08.i +``` diff --git a/docker/add_moose_examples.bash b/docker/add_moose_examples.bash new file mode 100755 index 0000000..02dd822 --- /dev/null +++ b/docker/add_moose_examples.bash @@ -0,0 +1,5 @@ +#!/bin/bash +git clone https://github.com/idaholab/moose.git /work/moose --branch 2025-05-09-release --depth 1 +cd /work/moose/examples +source /environment +make -j $(( $(nproc) - 2)) diff --git a/docker/run_peacock.bash b/docker/run_peacock.bash new file mode 100755 index 0000000..6d54720 --- /dev/null +++ b/docker/run_peacock.bash @@ -0,0 +1,4 @@ +#!/bin/bash + +export PYTHONPATH=/opt/moose/share/moose/python:/opt/paraview/lib/python3.12/site-packages:$PYTHONPATH +/work/venv/bin/peacock-trame --server --host 0.0.0.0 -L /work/moose-language-support/out/main.js $@ diff --git a/peacock_trame/app/fileEditor.py b/peacock_trame/app/fileEditor.py index dd36f7a..861c65e 100644 --- a/peacock_trame/app/fileEditor.py +++ b/peacock_trame/app/fileEditor.py @@ -39,6 +39,7 @@ try: from paraview import simple + # print("Using PV OpenGL Renderer: ", simple.GetOpenGLInformation().GetRenderer()) USE_PARAVIEW = True except ModuleNotFoundError: USE_PARAVIEW = False