Skip to content

Commit b05f931

Browse files
authored
Added Dockerfile and use in CI (#121)
2 parents 4819b99 + 183cf36 commit b05f931

File tree

3 files changed

+159
-124
lines changed

3 files changed

+159
-124
lines changed

.github/workflows/Dockerfile.stable

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Base Dockerfile for using stormpy
2+
###################################
3+
# The Docker image can be built by executing:
4+
# docker build -t yourusername/stormpy .
5+
# A different Storm base image can be set from the commandline with:
6+
# --build-arg STORM_BASE=<new_base_image>
7+
8+
# Set Storm base image
9+
ARG STORM_BASE=movesrwth/storm:stable
10+
FROM $STORM_BASE
11+
MAINTAINER Matthias Volk <[email protected]>
12+
13+
14+
# Configuration arguments
15+
#########################
16+
# The arguments can be set from the commandline with:
17+
# --build-arg <arg_name>=<value>
18+
19+
# CMake build type
20+
ARG build_type=Release
21+
# Additional arguments for compiling pycarl
22+
ARG setup_args_pycarl=""
23+
# Number of threads to use for parallel compilation
24+
ARG no_threads=2
25+
26+
27+
# Install dependencies
28+
######################
29+
# Uncomment to update packages beforehand
30+
RUN apt-get update -qq
31+
RUN apt-get install -y --no-install-recommends \
32+
maven \
33+
uuid-dev \
34+
python3 \
35+
python3-venv
36+
# Packages maven and uuid-dev are required for carl-parser
37+
38+
39+
# Build carl-parser
40+
###################
41+
WORKDIR /opt/
42+
43+
# Obtain carl-parser from public repository
44+
RUN git clone https://github.com/moves-rwth/carl-parser.git
45+
46+
# Switch to build directory
47+
RUN mkdir -p /opt/carl-parser/build
48+
WORKDIR /opt/carl-parser/build
49+
50+
# Configure carl-parser
51+
RUN cmake .. -DCMAKE_BUILD_TYPE=$build_type
52+
53+
# Build carl-parser
54+
RUN make carl-parser -j $no_threads
55+
56+
57+
# Set-up virtual environment
58+
############################
59+
ENV VIRTUAL_ENV=/opt/venv
60+
RUN python3 -m venv $VIRTUAL_ENV
61+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
62+
63+
64+
# Build pycarl
65+
##############
66+
WORKDIR /opt/
67+
68+
# Obtain latest version of pycarl from public repository
69+
RUN git clone https://github.com/moves-rwth/pycarl.git
70+
71+
# Switch to pycarl directory
72+
WORKDIR /opt/pycarl
73+
74+
# Build pycarl
75+
RUN python setup.py build_ext $setup_args_pycarl -j $no_threads develop
76+
77+
78+
# Build stormpy
79+
###############
80+
RUN mkdir /opt/stormpy
81+
WORKDIR /opt/stormpy
82+
83+
# Copy the content of the current local stormpy repository into the Docker image
84+
COPY . .
85+
86+
# Stormpy is built from outside to catch exit code

.github/workflows/buildtest.yml

Lines changed: 38 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,8 @@ on:
1616
env:
1717
GIT_URL: "${{ github.server_url }}/${{ github.repository }}.git"
1818
BRANCH: "${{ github.ref }}"
19-
# github runners currently have two cores
19+
# GitHub runners currently have two cores
2020
NR_JOBS: "2"
21-
CMAKE_DEBUG: "-DCMAKE_BUILD_TYPE=Debug"
22-
CMAKE_RELEASE: "-DCMAKE_BUILD_TYPE=Release"
23-
24-
CARL_PARSER_GIT_URL: "https://github.com/ths-rwth/carl-parser"
25-
CARL_PARSER_BRANCH: "master14"
26-
PYCARL_GIT_URL: "https://github.com/moves-rwth/pycarl.git"
27-
PYCARL_BRANCH: "master"
28-
2921

3022
jobs:
3123
indepthTests:
@@ -46,44 +38,22 @@ jobs:
4638
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
4739
# then the env variable with name NAME will be created/updated with VALUE
4840
run: |
49-
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "CMAKE_ARGS=${CMAKE_DEBUG}" || echo "CMAKE_ARGS=${CMAKE_RELEASE}") >> $GITHUB_ENV
41+
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "BUILD_TYPE=Debug" || echo "BUILD_TYPE=Release") >> $GITHUB_ENV
5042
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "IMG=${DEBUG_IMG}" || echo "IMG=${RELEASE_IMG}") >> $GITHUB_ENV
5143
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "DEBUG_SWITCH=--debug" || true) >> $GITHUB_ENV
5244
# Restrict tests to directory 'tests' (excluding examples and documentation) if not all libraries are present
5345
([[ "${{ matrix.setupArgs.disableFlags }}" != "" ]] && echo "TEST_OPT=--addopts tests" || true) >> $GITHUB_ENV
5446
55-
- name: Init Docker
56-
run: sudo docker run -d -it --name storm --privileged movesrwth/$IMG
57-
# We should not do partial updates :/
58-
# but we need to install some dependencies
59-
# Surely we can find a better way to do this at some point
60-
- name: Update base system
61-
run: |
62-
sudo docker exec storm apt-get update
63-
sudo docker exec storm apt-get upgrade -qqy
64-
- name: install dependencies
65-
run: sudo docker exec storm apt-get install -qq -y maven uuid-dev python3 python3-pip
6647
- name: Git clone
67-
run: |
68-
# git clone cannot clone individual commits based on a sha and some other refs
69-
# this workaround fixes this and fetches only one commit
70-
sudo docker exec storm bash -c "mkdir /opt/stormpy; cd /opt/stormpy; git init && git remote add origin ${GIT_URL} && git fetch --depth 1 origin ${BRANCH} && git checkout FETCH_HEAD"
71-
sudo docker exec storm git clone --depth 1 --branch $CARL_PARSER_BRANCH $CARL_PARSER_GIT_URL /opt/carl-parser
72-
sudo docker exec storm git clone --depth 1 --branch $PYCARL_BRANCH $PYCARL_GIT_URL /opt/pycarl
73-
- name: Run cmake for carl-parser
74-
run: sudo docker exec storm bash -c "mkdir /opt/carl-parser/build; cd /opt/carl-parser/build; cmake .. ${CMAKE_ARGS}"
75-
- name: make carl-parser
76-
run: sudo docker exec storm bash -c "cd /opt/carl-parser/build; make -j ${NR_JOBS}"
77-
- name: Build pycarl
78-
run: |
79-
sudo docker exec storm bash -c "cd /opt/pycarl; python3 setup.py build_ext $DEBUG_SWITCH -j ${NR_JOBS} develop"
80-
- name: Build stormpy
81-
run: |
82-
sudo docker exec storm bash -c "cd /opt/stormpy; python3 setup.py build_ext --storm-dir /opt/storm/build/ $DEBUG_SWITCH ${{ matrix.setupArgs.disableFlags }} -j ${NR_JOBS} develop"
83-
sudo docker exec storm bash -c "cd /opt/stormpy; pip3 install -e '.${{ matrix.setupArgs.optionalLibs }}'"
48+
uses: actions/checkout@v3
49+
- name: Build stormpy from Dockerfile
50+
run: docker build -t movesrwth/stormpy:ci-${{ matrix.debugOrRelease }} . --build-arg STORM_BASE=movesrwth/${IMG} --build-arg build_type=${BUILD_TYPE} --build-arg setup_args="${DEBUG_SWITCH} ${{ matrix.setupArgs.disableFlags }}" --build-arg setup_args_pycarl=${DEBUG_SWITCH} --build-arg no_threads=${NR_JOBS}
51+
- name: Run Docker
52+
run: docker run -d -it --name ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
53+
- name: Build optional stormpy libraries
54+
run: docker exec ci bash -c "cd /opt/stormpy; pip3 install -e '.${{ matrix.setupArgs.optionalLibs }}'"
8455
- name: Run tests
85-
run: |
86-
sudo docker exec storm bash -c "cd /opt/stormpy; python3 setup.py test $TEST_OPT"
56+
run: docker exec ci bash -c "cd /opt/stormpy; python setup.py test $TEST_OPT"
8757

8858

8959
stableTest:
@@ -103,40 +73,24 @@ jobs:
10373
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
10474
# then the env variable with name NAME will be created/updated with VALUE
10575
run: |
106-
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "CMAKE_ARGS=${CMAKE_DEBUG}" || echo "CMAKE_ARGS=${CMAKE_RELEASE}") >> $GITHUB_ENV
76+
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "BUILD_TYPE=Debug" || echo "BUILD_TYPE=Release") >> $GITHUB_ENV
10777
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "IMG=${DEBUG_IMG}" || echo "IMG=${RELEASE_IMG}") >> $GITHUB_ENV
10878
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "DEBUG_SWITCH=--debug" || true) >> $GITHUB_ENV
10979
110-
- name: Init Docker
111-
run: sudo docker run -d -it --name storm --privileged movesrwth/$IMG
112-
# We should not do partial updates :/
113-
# but we need to install some dependencies
114-
# Surely we can find a better way to do this at some point
115-
- name: Update base system
116-
run: |
117-
sudo docker exec storm apt-get update
118-
sudo docker exec storm apt-get upgrade -qqy
119-
- name: install dependencies
120-
run: sudo docker exec storm apt-get install -qq -y maven uuid-dev python3 python3-pip
12180
- name: Git clone
122-
run: |
123-
# git clone cannot clone individual commits based on a sha and some other refs
124-
# this workaround fixes this and fetches only one commit
125-
sudo docker exec storm bash -c "mkdir /opt/stormpy; cd /opt/stormpy; git init && git remote add origin ${GIT_URL} && git fetch --depth 1 origin ${BRANCH} && git checkout FETCH_HEAD"
126-
sudo docker exec storm git clone --depth 1 --branch $CARL_PARSER_BRANCH $CARL_PARSER_GIT_URL /opt/carl-parser
127-
sudo docker exec storm git clone --depth 1 --branch $PYCARL_BRANCH $PYCARL_GIT_URL /opt/pycarl
128-
- name: Run cmake for carl-parser
129-
run: sudo docker exec storm bash -c "mkdir /opt/carl-parser/build; cd /opt/carl-parser/build; cmake .. ${CMAKE_ARGS}"
130-
- name: make carl-parser
131-
run: sudo docker exec storm bash -c "cd /opt/carl-parser/build; make -j ${NR_JOBS}"
132-
- name: Build pycarl
133-
run: |
134-
sudo docker exec storm bash -c "cd /opt/pycarl; python3 setup.py build_ext $DEBUG_SWITCH -j ${NR_JOBS} develop"
81+
uses: actions/checkout@v3
82+
- name: Replace Dockerfile
83+
run: cp .github/workflows/Dockerfile.stable Dockerfile
84+
- name: Build dependencies
85+
run: docker build -t movesrwth/stormpy:ci-${{ matrix.debugOrRelease }} . --build-arg STORM_BASE=movesrwth/${IMG} --build-arg build_type=${BUILD_TYPE} --build-arg setup_args_pycarl=${DEBUG_SWITCH} --build-arg no_threads=${NR_JOBS}
86+
- name: Run Docker
87+
run: docker run -d -it --name ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
13588
- name: Build stormpy
89+
# Build stormpy explicitly to catch exit code
13690
id: build_stormpy
13791
shell: bash {0} // Deactivate fast-fail to handle exit code for incompatibility
13892
run: |
139-
sudo docker exec storm bash -c "cd /opt/stormpy; python3 setup.py build_ext --storm-dir /opt/storm/build/ $DEBUG_SWITCH -j ${NR_JOBS} develop"
93+
docker exec ci bash -c "cd /opt/stormpy; python setup.py build_ext ${DEBUG_SWITCH} -j ${NR_JOBS} develop"
14094
status=$?
14195
if [ $status -eq 42 ]; then
14296
# Warn about incompatibility but do not handle as failure
@@ -149,8 +103,7 @@ jobs:
149103
fi
150104
- name: Run tests
151105
if: steps.build_stormpy.outputs.run_tests == 'true'
152-
run: |
153-
sudo docker exec storm bash -c "cd /opt/stormpy; python3 setup.py test"
106+
run: docker exec ci bash -c "cd /opt/stormpy; python setup.py test"
154107

155108

156109
deploy:
@@ -172,62 +125,37 @@ jobs:
172125
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "IMG=${DEBUG_IMG}" || echo "IMG=${RELEASE_IMG}") >> $GITHUB_ENV
173126
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "DEBUG_SWITCH=--debug" || true) >> $GITHUB_ENV
174127
175-
- name: Login into docker
176-
# Only login if using master on original repo (and not for pull requests or forks)
177-
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
178-
run: echo "${{ secrets.STORM_CI_DOCKER_PASSWORD }}" | sudo docker login -u "${{ secrets.STORM_CI_DOCKER_USERNAME }}" --password-stdin
179-
- name: Init Docker
180-
run: sudo docker run -d -it --name storm --privileged movesrwth/$IMG
181-
182-
# We should not do partial updates :/
183-
# but we need to install some dependencies
184-
# Surely we can find a better way to do this at some point
185-
- name: Update base system
186-
run: |
187-
sudo docker exec storm apt-get update
188-
sudo docker exec storm apt-get upgrade -qqy
189-
- name: install dependencies
190-
run: sudo docker exec storm apt-get install -qq -y maven uuid-dev python3 python3-pip
191128
- name: Git clone
192-
run: |
193-
# git clone cannot clone individual commits based on a sha and some other refs
194-
# this workaround fixes this and fetches only one commit
195-
sudo docker exec storm bash -c "mkdir /opt/stormpy; cd /opt/stormpy; git init && git remote add origin ${GIT_URL} && git fetch --depth 1 origin ${BRANCH} && git checkout FETCH_HEAD"
196-
sudo docker exec storm git clone --depth 1 --branch $CARL_PARSER_BRANCH $CARL_PARSER_GIT_URL /opt/carl-parser
197-
sudo docker exec storm git clone --depth 1 --branch $PYCARL_BRANCH $PYCARL_GIT_URL /opt/pycarl
198-
- name: Run cmake for carl-parser
199-
run: sudo docker exec storm bash -c "mkdir /opt/carl-parser/build; cd /opt/carl-parser/build; cmake .. ${CMAKE_ARGS}"
200-
- name: make carl-parser
201-
run: sudo docker exec storm bash -c "cd /opt/carl-parser/build; make -j ${NR_JOBS}"
202-
203-
- name: Build pycarl
204-
run: |
205-
sudo docker exec storm bash -c "cd /opt/pycarl; python3 setup.py build_ext $DEBUG_SWITCH -j ${NR_JOBS} develop"
206-
- name: Build stormpy
207-
run: |
208-
sudo docker exec storm bash -c "cd /opt/stormpy; python3 setup.py build_ext --storm-dir /opt/storm/build/ $DEBUG_SWITCH -j ${NR_JOBS} develop"
129+
uses: actions/checkout@v3
130+
- name: Build stormpy from Dockerfile
131+
run: docker build -t movesrwth/stormpy:ci-${{ matrix.debugOrRelease }} . --build-arg STORM_BASE=movesrwth/${IMG} --build-arg build_type=${BUILD_TYPE} --build-arg setup_args=${DEBUG_SWITCH} --build-arg setup_args_pycarl=${DEBUG_SWITCH} --build-arg no_threads=${NR_JOBS}
132+
- name: Run Docker
133+
run: docker run -d -it --name ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
209134
- name: Run tests
210-
run: |
211-
sudo docker exec storm bash -c "cd /opt/stormpy; python3 setup.py test"
135+
run: docker exec ci bash -c "cd /opt/stormpy; python setup.py test"
212136

137+
- name: Login into docker
138+
# Only login if using master on original repo (and not for pull requests or forks)
139+
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
140+
run: echo "${{ secrets.STORM_CI_DOCKER_PASSWORD }}" | docker login -u "${{ secrets.STORM_CI_DOCKER_USERNAME }}" --password-stdin
213141
- name: Deploy stormpy
214142
# Only deploy if using master on original repo (and not for pull requests or forks)
215143
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
216144
run: |
217-
sudo docker commit storm movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
218-
sudo docker push movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
145+
docker commit ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
146+
docker push movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
219147
220148
- name: Install documentation dependencies
221149
if: matrix.debugOrRelease == 'release'
222150
run: |
223-
sudo docker exec storm apt-get install -qq -y pandoc
224-
sudo docker exec storm bash -c "cd /opt/stormpy; pip3 install -e '.[doc,numpy]'"
151+
docker exec ci apt-get install -qq -y pandoc
152+
docker exec ci bash -c "cd /opt/stormpy; pip install -e '.[doc,numpy]'"
225153
- name: Build documentation
226154
if: matrix.debugOrRelease == 'release'
227155
run: |
228-
sudo docker exec storm bash -c "cd /opt/stormpy/doc; make html"
229-
sudo docker exec storm rm -r /opt/stormpy/doc/build/html/_sources
230-
sudo docker cp storm:/opt/stormpy/doc/build/html .
156+
docker exec ci bash -c "cd /opt/stormpy/doc; make html"
157+
docker exec ci rm -r /opt/stormpy/doc/build/html/_sources
158+
docker cp ci:/opt/stormpy/doc/build/html .
231159
- name: Deploy documentation
232160
# Only deploy for release version and using master on original repo (and not for pull requests or forks)
233161
if: matrix.debugOrRelease == 'release' && github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'

Dockerfile

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@
22
###################################
33
# The Docker image can be built by executing:
44
# docker build -t yourusername/stormpy .
5+
# A different Storm base image can be set from the commandline with:
6+
# --build-arg STORM_BASE=<new_base_image>
57

6-
FROM movesrwth/storm:1.6.4
7-
# Change to movesrwth/storm:ci-release for the latest build
8-
# or your own container
8+
# Set Storm base image
9+
ARG STORM_BASE=movesrwth/storm:stable
10+
FROM $STORM_BASE
911
MAINTAINER Matthias Volk <[email protected]>
1012

11-
# Specify number of threads to use for parallel compilation
12-
# This number can be set from the commandline with:
13-
# --build-arg no_threads=<value>
14-
ARG no_threads=1
13+
14+
# Configuration arguments
15+
#########################
16+
# The arguments can be set from the commandline with:
17+
# --build-arg <arg_name>=<value>
18+
19+
# CMake build type
20+
ARG build_type=Release
21+
# Additional arguments for compiling stormpy
22+
ARG setup_args=""
23+
# Additional arguments for compiling pycarl
24+
ARG setup_args_pycarl=""
25+
# Number of threads to use for parallel compilation
26+
ARG no_threads=2
1527

1628

1729
# Install dependencies
1830
######################
1931
# Uncomment to update packages beforehand
20-
# RUN apt-get update -qq
32+
RUN apt-get update -qq
2133
RUN apt-get install -y --no-install-recommends \
2234
maven \
2335
uuid-dev \
2436
python3 \
25-
python3-pip
37+
python3-venv
2638
# Packages maven and uuid-dev are required for carl-parser
2739

2840

@@ -31,19 +43,26 @@ RUN apt-get install -y --no-install-recommends \
3143
WORKDIR /opt/
3244

3345
# Obtain carl-parser from public repository
34-
RUN git clone -b master14 https://github.com/ths-rwth/carl-parser.git
46+
RUN git clone https://github.com/moves-rwth/carl-parser.git
3547

3648
# Switch to build directory
3749
RUN mkdir -p /opt/carl-parser/build
3850
WORKDIR /opt/carl-parser/build
3951

4052
# Configure carl-parser
41-
RUN cmake .. -DCMAKE_BUILD_TYPE=Release
53+
RUN cmake .. -DCMAKE_BUILD_TYPE=$build_type
4254

4355
# Build carl-parser
4456
RUN make carl-parser -j $no_threads
4557

4658

59+
# Set-up virtual environment
60+
############################
61+
ENV VIRTUAL_ENV=/opt/venv
62+
RUN python3 -m venv $VIRTUAL_ENV
63+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
64+
65+
4766
# Build pycarl
4867
##############
4968
WORKDIR /opt/
@@ -55,8 +74,7 @@ RUN git clone https://github.com/moves-rwth/pycarl.git
5574
WORKDIR /opt/pycarl
5675

5776
# Build pycarl
58-
RUN python3 setup.py build_ext -j $no_threads develop
59-
77+
RUN python setup.py build_ext $setup_args_pycarl -j $no_threads develop
6078

6179

6280
# Build stormpy
@@ -68,4 +86,7 @@ WORKDIR /opt/stormpy
6886
COPY . .
6987

7088
# Build stormpy
71-
RUN python3 setup.py build_ext -j $no_threads develop
89+
RUN python setup.py build_ext $setup_args -j $no_threads develop
90+
91+
# Uncomment to build optional dependencies
92+
#RUN pip install -e '.[doc,numpy]'"

0 commit comments

Comments
 (0)