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

WIP: Support for running tutorials using Docker #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions Dockerfiles/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build:
$(MAKE) -C helics build
$(MAKE) -C griddyn build
$(MAKE) -C gridlab-d build
$(MAKE) -C psst build
$(MAKE) -C runner build
8 changes: 8 additions & 0 deletions Dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Dockerfiles

A Dockerfile exists for each component (ie. federate) needed for the
tutorials. The Docker Compose files for each tutorials will reference
the relevant Dockerfiles as the `build` argument for each container.
Alternatively, each image can be built by running `make build` in the
relevant directory, or all the images can be built by running `make
build` in this directory.
37 changes: 37 additions & 0 deletions Dockerfiles/griddyn/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM helics as builder

RUN apt update && apt install -y \
libboost-dev libboost-chrono-dev \
libboost-date-time-dev libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev libboost-test-dev \
libboost-timer-dev libsuitesparse-dev \
libzmq3-dev libklu1 \
build-essential cmake git

WORKDIR /root/develop

RUN git clone --single-branch -b cmake_update https://github.com/LLNL/GridDyn.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a specific commit for the HELICS-Tutorial. Same for GridLAB-D, HELICS, GridDyn, psst etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdheepak I'm assuming you mean update each Dockerfile that's cloning a git repo to use a specific branch, tag, or commit? I think I'm doing that in most, at least a specific branch... perhaps you're suggesting an actual commit hash just in case the branch goes away?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I meant to say specific commit hash. In case the branch goes away when merged to another / is updated etc, this will still work. It gives more of a guarantee of reproducibility than just using the branch name.


WORKDIR /root/develop/GridDyn

ADD fmi-patch.diff .
RUN git apply fmi-patch.diff

WORKDIR /root/develop/GridDyn/build

RUN cmake -DHELICS_EXECUTABLE=ON .. && make -j8 install

FROM ubuntu:18.04

RUN apt update && apt install -y --no-install-recommends \
libboost-chrono1.65.1 libboost-date-time1.65.1 \
libboost-filesystem1.65.1 libboost-program-options1.65.1 \
libboost-system1.65.1 libboost-test1.65.1 \
libboost-timer1.65.1 libzmq5 libklu1 libgomp1 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/local /usr/local/

# FIXME
CMD ["gridDynMain", "--version"]
4 changes: 4 additions & 0 deletions Dockerfiles/griddyn/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME := griddyn

build:
docker build -t $(NAME) .
14 changes: 14 additions & 0 deletions Dockerfiles/griddyn/fmi-patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/fmi/CMakeLists.txt b/src/fmi/CMakeLists.txt
index 63f35f7..4ffd693 100644
--- a/src/fmi/CMakeLists.txt
+++ b/src/fmi/CMakeLists.txt
@@ -78,7 +78,7 @@ source_group("FMUImport" FILES ${fmiImport_sources} ${fmiImport_headers})

set_target_properties(fmiGDLibrary PROPERTIES FOLDER fmi)

-target_link_libraries(fmiGDLibrary griddyn formatInterpreter)
+target_link_libraries(fmiGDLibrary griddyn formatInterpreter ${CMAKE_DL_LIBS})

install(
TARGETS fmiGDLibrary

36 changes: 36 additions & 0 deletions Dockerfiles/gridlab-d/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM helics as builder

RUN apt update && apt install -y \
libboost-dev libboost-chrono-dev \
libboost-date-time-dev libboost-filesystem-dev \
libboost-program-options-dev \
libboost-test-dev libboost-timer-dev \
libzmq3-dev libtool libxerces-c-dev \
build-essential automake git


WORKDIR /root/develop

RUN git clone --single-branch -b develop https://github.com/gridlab-d/gridlab-d.git

WORKDIR /root/develop/gridlab-d

RUN autoreconf -if \
&& ./configure --prefix=/usr/local --with-helics=/usr/local --enable-silent-rules \
"CFLAGS=-g -O0 -w" "CXXFLAGS=-g -O0 -w -std=c++14" "LDFLAGS=-g -O0 -w" \
&& make -j8 install

FROM ubuntu:18.04

RUN apt update && apt install -y --no-install-recommends \
libboost-chrono1.65.1 libboost-date-time1.65.1 \
libboost-filesystem1.65.1 libboost-program-options1.65.1 \
libboost-test1.65.1 libboost-timer1.65.1 \
libzmq5 libxerces-c3.2 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/local /usr/local/

ENV LD_LIBRARY_PATH=/usr/local/lib

CMD ["gridlabd", "--version"]
4 changes: 4 additions & 0 deletions Dockerfiles/gridlab-d/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME := gridlab-d

build:
docker build -t $(NAME) .
42 changes: 42 additions & 0 deletions Dockerfiles/helics/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM ubuntu:18.04 as builder

RUN apt update && apt install -y \
libboost-dev libboost-chrono-dev \
libboost-date-time-dev libboost-filesystem-dev \
libboost-program-options-dev \
libboost-test-dev libboost-timer-dev \
libzmq3-dev python3-dev \
build-essential swig cmake git

WORKDIR /root/develop

RUN git clone https://github.com/GMLC-TDC/HELICS-src.git helics

WORKDIR /root/develop/helics/build

RUN cmake \
-DBUILD_PYTHON_INTERFACE=ON \
-DBUILD_CXX_SHARED_LIB=ON \
-DPYTHON_INCLUDE_DIR=/usr/include/python3.6/ \
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so \
-DCMAKE_INSTALL_PREFIX=/helics \
..
RUN make -j8 install

FROM ubuntu:18.04

RUN apt update && apt install -y --no-install-recommends \
libboost-chrono1.65.1 libboost-date-time1.65.1 \
libboost-filesystem1.65.1 libboost-program-options1.65.1 \
libboost-test1.65.1 libboost-timer1.65.1 libzmq5

COPY --from=builder /helics /usr/local/

ENV PYTHONPATH /usr/local/python

# Python must be installed after the PYTHONPATH is set above for it to
# recognize and import libhelicsSharedLib.so.
RUN apt install -y --no-install-recommends python3-dev \
&& rm -rf /var/lib/apt/lists/*

CMD ["python3", "-c", "import helics; print(helics.helicsGetVersion())"]
4 changes: 4 additions & 0 deletions Dockerfiles/helics/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME := helics

build:
docker build --no-cache -t $(NAME) .
27 changes: 27 additions & 0 deletions Dockerfiles/psst/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM helics as builder

RUN apt update && apt install -y \
python3-pip git

RUN pip3 install scipy

WORKDIR /root/develop

RUN git clone https://github.com/kdheepak/psst.git

WORKDIR /root/develop/psst

RUN pip3 install . \
&& cp -a psst/* /usr/local/lib/python3.6/dist-packages/psst

FROM ubuntu:18.04

RUN apt update && apt install -y --no-install-recommends \
python3-pkg-resources python3-six python3-setuptools python3-idna \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/local /usr/local/

ENV LC_ALL=C.UTF-8 LANG=C.UTF-8

CMD ["psst", "--version"]
4 changes: 4 additions & 0 deletions Dockerfiles/psst/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME := psst

build:
docker build -t $(NAME) .
21 changes: 21 additions & 0 deletions Dockerfiles/runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM helics as builder

RUN apt update && apt install -y \
python3-pip git

RUN pip3 install git+git://github.com/GMLC-TDC/helics-runner.git@master

FROM ubuntu:18.04

RUN apt update && apt install -y --no-install-recommends \
python3-pkg-resources python3-six \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/local /usr/local/

ENV LC_ALL=C.UTF-8 LANG=C.UTF-8

# The config file defaults to calling `python`.
RUN ln -s /usr/bin/python3 /usr/bin/python

CMD ["helics", "--version"]
4 changes: 4 additions & 0 deletions Dockerfiles/runner/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME := helics-runner

build:
docker build -t $(NAME) .
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ that include Transmission, Distribution, Markets and Communication federates.
Table of Contents:

- [Setup](./setup/README.md)
- [Dockerfiles](./Dockerfiles/README.md)
- [Tutorials](./tutorials/README.md)
30 changes: 30 additions & 0 deletions tutorials/1-DistributionFederation-ManualStart/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3'
services:
broker:
build: ../../Dockerfiles/helics
command:
- helics_broker
- '2'
- --loglevel=3
- --name=mainbroker
image: helics
federate:
build: ../../Dockerfiles/helics
command:
- python3
- federate1.py
image: helics
volumes:
- ../../:/helics-tutorial
working_dir: /helics-tutorial/tutorials/1-DistributionFederation-ManualStart
gridlab-d:
build: ../../Dockerfiles/gridlab-d
command:
- gridlabd
- DistributionSim_B2_G_1.glm
environment:
- LD_LIBRARY_PATH=/usr/local/lib
image: gridlab-d
volumes:
- ../../:/helics-tutorial
working_dir: /helics-tutorial/test_system_data/gldFeeders/B2/G_1
14 changes: 14 additions & 0 deletions tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@ This is an example of 11 GridLAB-D HELICS Federates, a GridDyn HELICS Federate,
This is an example of 11 GridLAB-D HELICS Federates, a GridDyn HELICS Federate, a FESTIVLite HELICS Federate, and a HELICS Broker.
In addition it includes communication delay filter.

### Docker Compose

Each tutorial contains a `docker-compose.yml` file that can be used with
Docker Compose to run the tutorial using Docker containers.

For example:

```
$> cd tutorials/1-DistributionFederation-ManualStart
$> docker-compose up
```

If the relevant Docker images need to be built, Docker Compose will take
care of building them before running the tutorial. If this is the case,
go grab some :coffee: while the images build... it'll be a while.