Skip to content
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

Adapt DPsim to deploy it in Mybinder #323

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "examples/Notebooks/MSP-lecture"]
path = examples/Notebooks/MSP-lecture
url = https://git.rwth-aachen.de/acs/public/teaching/msp/notebooks.git
1 change: 1 addition & 0 deletions Dockerfile
7 changes: 7 additions & 0 deletions apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gcc
gcc-c++
clang
make
cmake
pkgconfig
cppcheck
1 change: 1 addition & 0 deletions examples/Notebooks/MSP-lecture
Submodule MSP-lecture added at 628f94
128 changes: 128 additions & 0 deletions packaging/Docker/Dockerfile.mybinder
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
FROM fedora:36 AS base

ARG CIM_VERSION=CGMES_2.4.15_16FEB2016
ARG VILLAS_VERSION=411b0ad49e2629ad41c6918d2a6c51e9a72220b4

ARG CMAKE_OPTS
ARG MAKE_OPTS=-j4

ARG NotebookApp.default_url
ARG ip
ARG port

LABEL \
org.opencontainers.image.title="DPsim" \
org.opencontainers.image.licenses="MPL 2.0" \
org.opencontainers.image.url="http://dpsim.fein-aachen.org/" \
org.opencontainers.image.source="https://github.com/sogno-platform/dpsim"

RUN dnf -y update

# Toolchain
RUN dnf -y install \
gcc gcc-c++ clang \
git \
rpmdevtools rpm-build \
make cmake pkgconfig \
python3-pip \
cppcheck

# Tools needed for developement
RUN dnf -y install \
doxygen graphviz \
gdb \
procps-ng

# Dependencies
RUN dnf --refresh -y install \
python3-devel \
eigen3-devel \
libxml2-devel \
graphviz-devel \
spdlog-devel \
fmt-devel

# Install some debuginfos
RUN dnf -y debuginfo-install \
python3

# Build & Install sundials
RUN cd /tmp && \
git clone --branch v3.2.1 --recurse-submodules --depth 1 https://github.com/LLNL/sundials.git && \
mkdir -p sundials/build && cd sundials/build && \
cmake ${CMAKE_OPTS} .. \
-DCMAKE_BUILD_TYPE=Release && \
make ${MAKE_OPTS} install

# CIMpp and VILLASnode are installed here
ENV LD_LIBRARY_PATH="/usr/local/lib64:${LD_LIBRARY_PATH}"

# Install minimal VILLASnode dependencies
RUN dnf -y install \
openssl-devel \
libuuid-devel \
libcurl-devel \
jansson-devel \
libwebsockets-devel

# Install optional VILLASnode dependencies
RUN dnf -y install \
mosquitto-devel \
libconfig-devel \
libnl3-devel

# Python dependencies
ADD requirements.txt .

Check notice

Code scanning / SonarCloud

Prefer COPY over ADD for copying local resources Low

Replace this ADD instruction with a COPY instruction. See more on SonarQube Cloud
RUN pip3 install --upgrade wheel build
RUN pip3 install -r requirements.txt

# Install CIMpp from source
RUN cd /tmp && \
git clone --recurse-submodules --depth 1 https://github.com/cim-iec/libcimpp.git && \
mkdir -p libcimpp/build && cd libcimpp/build && \
cmake ${CMAKE_OPTS} ..\
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 \
-DUSE_CIM_VERSION=${CIM_VERSION} \
-DBUILD_ARABICA_EXAMPLES=OFF && \
make ${MAKE_OPTS} install && \
rm -rf /tmp/libcimpp

# Install VILLASnode from source
RUN cd /tmp && \
git clone --recurse-submodules https://github.com/VILLASframework/node.git villas-node && \
mkdir -p villas-node/build && cd villas-node/build && \
git checkout ${VILLAS_VERSION} && \
cmake ${CMAKE_OPTS} .. \
-DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 \
-DDOWNLOAD_GO=OFF && \
make ${MAKE_OPTS} install && \
rm -rf /tmp/villas-node

RUN pip3 install --no-cache \
jupyter \
jupyterlab \
jupyter_contrib_nbextensions \
nbconvert \
nbformat

ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}

RUN adduser \
--comment "Default user" \
--uid ${NB_UID} \
${NB_USER}

COPY . ${HOME}/dpsim
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}
RUN rm -rf ${HOME}/dpsim/build && mkdir ${HOME}/dpsim/build
WORKDIR ${HOME}/dpsim

RUN python3 -m build --wheel
RUN python3 -m pip install ./dist/dpsim*
Loading