tools/docker: Add internal doc

This commit is contained in:
Corentin Le Molgat
2021-09-06 13:08:03 +02:00
parent 288c3709a7
commit 5570bc855a
4 changed files with 295 additions and 0 deletions

44
tools/docker/README.md Normal file
View File

@@ -0,0 +1,44 @@
# CI: Makefile/Docker testing
To test the build on various distro, we are using docker containers and a Makefile for orchestration.
pros:
* You are independent of third party CI runner config (e.g. github actions runners or Travis-CI VM images).
* You can run it locally on any unix system.
* Most CI provide runner with docker and Makefile installed.
cons:
* Only GNU/Linux distro supported.
* Could take few GiB (~30 GiB for all distro and all languages)
* ~500MiB OS + C++/CMake tools,
* ~150 MiB Python, wheel,
# Usage
To get the help simply type:
```sh
make
```
note: you can also use from top directory
```sh
make --directory=tools/docker
```
## Example
For example to test inside an `Alpine` container:
```sh
make alpine-edge_test
```
# Docker layers
Dockerfile is splitted in several stages.
![docker](doc/deps.svg)
## Docker aarch64 on x86_64 machine
You can build and run aarch64 docker container on a x86_64 by enabling qemu support:
```sh
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
```
ref: https://github.com/multiarch/qemu-user-static#getting-started

46
tools/docker/doc/deps.dot Normal file
View File

@@ -0,0 +1,46 @@
@startdot
digraph DockerDeps {
//rankdir=BT;
rankdir=TD;
node [shape=cylinder, style="rounded,filled", color=black, fillcolor=royalblue];
DISTRO_IMG [label="<distro>:latest"];
PKG [label="Build packages\ne.g. cmake, g++", shape=box3d];
PYPKG [label="Python packages\ne.g. python-dev", shape=box3d, fillcolor=gold];
JAVAPKG [label="Java packages\ne.g. openjdk", shape=box3d, fillcolor=crimson];
DOTNETPKG [label=".Net packages\ne.g. dotnet-cli", shape=box3d, fillcolor=forestgreen];
SRC [label="git repo", shape=folder];
subgraph clusterDockerfile {
ENV_IMG [label="or-tools/docker:<distro>_env\nenv"];
DEVEL_IMG [label="or-tools/docker:<distro>_devel\ndevel"];
TP_IMG [label="or-tools/docker:<distro>_third_party\nthird_party"];
BUILD_IMG [label="or-tools/docker:<distro>_build\nbuild"];
ENV_IMG -> DEVEL_IMG;
DEVEL_IMG -> TP_IMG;
TP_IMG -> BUILD_IMG;
color=royalblue;
label = "docker/<distro>/Dockerfile";
}
DISTRO_IMG -> ENV_IMG;
PKG -> ENV_IMG [label="install", style="dashed"];
PYPKG -> ENV_IMG [label="install", style="dashed"];
JAVAPKG -> ENV_IMG [label="install", style="dashed"];
DOTNETPKG -> ENV_IMG [label="install", style="dashed"];
SRC -> DEVEL_IMG [label="copy", style="dashed"];
subgraph clusterCache {
node [shape=note, style="rounded,filled", color=black, fillcolor=royalblue];
OR_TAR [label="or-tools_<distro>_vX.Y.Z.tar.gz"];
FLATZINC_TAR [label="or-tools_flatzinc_<distro>_vX.Y.Z.tar.gz"];
edge [color=red];
BUILD_IMG -> OR_TAR [label="make <distro>_archive"];
BUILD_IMG -> FLATZINC_TAR [label="make <distro>_archive"];
color=royalblue;
label = "export/archives/";
}
}
@enddot

197
tools/docker/doc/deps.svg Normal file
View File

@@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.43.0 (0)
-->
<!-- Title: DockerDeps Pages: 1 -->
<svg width="652pt" height="576pt"
viewBox="0.00 0.00 652.00 576.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 572)">
<title>DockerDeps</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-572 648,-572 648,4 -4,4"/>
<g id="clust1" class="cluster">
<title>clusterDockerfile</title>
<polygon fill="none" stroke="royalblue" points="165,-116 165,-489 399,-489 399,-116 165,-116"/>
<text text-anchor="middle" x="282" y="-473.8" font-family="Times,serif" font-size="14.00">docker/&lt;distro&gt;/Dockerfile</text>
</g>
<g id="clust2" class="cluster">
<title>clusterCache</title>
<polygon fill="none" stroke="royalblue" points="168,-8 168,-83 636,-83 636,-8 168,-8"/>
<text text-anchor="middle" x="402" y="-67.8" font-family="Times,serif" font-size="14.00">export/archives/</text>
</g>
<!-- DISTRO_IMG -->
<g id="node1" class="node">
<title>DISTRO_IMG</title>
<path fill="royalblue" stroke="black" d="M96,-563.73C96,-565.53 74.49,-567 48,-567 21.51,-567 0,-565.53 0,-563.73 0,-563.73 0,-534.27 0,-534.27 0,-532.47 21.51,-531 48,-531 74.49,-531 96,-532.47 96,-534.27 96,-534.27 96,-563.73 96,-563.73"/>
<path fill="none" stroke="black" d="M96,-563.73C96,-561.92 74.49,-560.45 48,-560.45 21.51,-560.45 0,-561.92 0,-563.73"/>
<text text-anchor="middle" x="48" y="-545.3" font-family="Times,serif" font-size="14.00">&lt;distro&gt;:latest</text>
</g>
<!-- ENV_IMG -->
<g id="node7" class="node">
<title>ENV_IMG</title>
<path fill="royalblue" stroke="black" d="M382,-453.35C382,-455.99 342.56,-458.13 294,-458.13 245.44,-458.13 206,-455.99 206,-453.35 206,-453.35 206,-410.4 206,-410.4 206,-407.76 245.44,-405.62 294,-405.62 342.56,-405.62 382,-407.76 382,-410.4 382,-410.4 382,-453.35 382,-453.35"/>
<path fill="none" stroke="black" d="M382,-453.35C382,-450.72 342.56,-448.58 294,-448.58 245.44,-448.58 206,-450.72 206,-453.35"/>
<text text-anchor="middle" x="294" y="-435.68" font-family="Times,serif" font-size="14.00">or&#45;tools/docker:&lt;distro&gt;_env</text>
<text text-anchor="middle" x="294" y="-420.68" font-family="Times,serif" font-size="14.00">env</text>
</g>
<!-- DISTRO_IMG&#45;&gt;ENV_IMG -->
<g id="edge4" class="edge">
<title>DISTRO_IMG&#45;&gt;ENV_IMG</title>
<path fill="none" stroke="black" d="M83.25,-531.51C121.73,-513.49 184.14,-484.29 231.07,-462.33"/>
<polygon fill="black" stroke="black" points="232.67,-465.44 240.24,-458.03 229.7,-459.1 232.67,-465.44"/>
</g>
<!-- PKG -->
<g id="node2" class="node">
<title>PKG</title>
<polygon fill="royalblue" stroke="black" points="221.5,-568 118.5,-568 114.5,-564 114.5,-530 217.5,-530 221.5,-534 221.5,-568"/>
<polyline fill="none" stroke="black" points="217.5,-564 114.5,-564 "/>
<polyline fill="none" stroke="black" points="217.5,-564 217.5,-530 "/>
<polyline fill="none" stroke="black" points="217.5,-564 221.5,-568 "/>
<text text-anchor="middle" x="168" y="-552.8" font-family="Times,serif" font-size="14.00">Build packages</text>
<text text-anchor="middle" x="168" y="-537.8" font-family="Times,serif" font-size="14.00">e.g. cmake, g++</text>
</g>
<!-- PKG&#45;&gt;ENV_IMG -->
<g id="edge5" class="edge">
<title>PKG&#45;&gt;ENV_IMG</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M187.97,-529.76C206.92,-512.44 235.82,-486.03 258.67,-465.15"/>
<polygon fill="black" stroke="black" points="261.14,-467.64 266.16,-458.31 256.42,-462.47 261.14,-467.64"/>
<text text-anchor="middle" x="241" y="-500.8" font-family="Times,serif" font-size="14.00">install</text>
</g>
<!-- PYPKG -->
<g id="node3" class="node">
<title>PYPKG</title>
<polygon fill="gold" stroke="black" points="348,-568 244,-568 240,-564 240,-530 344,-530 348,-534 348,-568"/>
<polyline fill="none" stroke="black" points="344,-564 240,-564 "/>
<polyline fill="none" stroke="black" points="344,-564 344,-530 "/>
<polyline fill="none" stroke="black" points="344,-564 348,-568 "/>
<text text-anchor="middle" x="294" y="-552.8" font-family="Times,serif" font-size="14.00">Python packages</text>
<text text-anchor="middle" x="294" y="-537.8" font-family="Times,serif" font-size="14.00">e.g. python&#45;dev</text>
</g>
<!-- PYPKG&#45;&gt;ENV_IMG -->
<g id="edge6" class="edge">
<title>PYPKG&#45;&gt;ENV_IMG</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M294,-529.76C294,-513.34 294,-488.76 294,-468.47"/>
<polygon fill="black" stroke="black" points="297.5,-468.31 294,-458.31 290.5,-468.31 297.5,-468.31"/>
<text text-anchor="middle" x="311" y="-500.8" font-family="Times,serif" font-size="14.00">install</text>
</g>
<!-- JAVAPKG -->
<g id="node4" class="node">
<title>JAVAPKG</title>
<polygon fill="crimson" stroke="black" points="460,-568 370,-568 366,-564 366,-530 456,-530 460,-534 460,-568"/>
<polyline fill="none" stroke="black" points="456,-564 366,-564 "/>
<polyline fill="none" stroke="black" points="456,-564 456,-530 "/>
<polyline fill="none" stroke="black" points="456,-564 460,-568 "/>
<text text-anchor="middle" x="413" y="-552.8" font-family="Times,serif" font-size="14.00">Java packages</text>
<text text-anchor="middle" x="413" y="-537.8" font-family="Times,serif" font-size="14.00">e.g. openjdk</text>
</g>
<!-- JAVAPKG&#45;&gt;ENV_IMG -->
<g id="edge7" class="edge">
<title>JAVAPKG&#45;&gt;ENV_IMG</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M394.14,-529.76C376.32,-512.52 349.18,-486.26 327.65,-465.43"/>
<polygon fill="black" stroke="black" points="329.91,-462.75 320.29,-458.31 325.04,-467.78 329.91,-462.75"/>
<text text-anchor="middle" x="392" y="-500.8" font-family="Times,serif" font-size="14.00">install</text>
</g>
<!-- DOTNETPKG -->
<g id="node5" class="node">
<title>DOTNETPKG</title>
<polygon fill="forestgreen" stroke="black" points="571.5,-568 482.5,-568 478.5,-564 478.5,-530 567.5,-530 571.5,-534 571.5,-568"/>
<polyline fill="none" stroke="black" points="567.5,-564 478.5,-564 "/>
<polyline fill="none" stroke="black" points="567.5,-564 567.5,-530 "/>
<polyline fill="none" stroke="black" points="567.5,-564 571.5,-568 "/>
<text text-anchor="middle" x="525" y="-552.8" font-family="Times,serif" font-size="14.00">.Net packages</text>
<text text-anchor="middle" x="525" y="-537.8" font-family="Times,serif" font-size="14.00">e.g. dotnet&#45;cli</text>
</g>
<!-- DOTNETPKG&#45;&gt;ENV_IMG -->
<g id="edge8" class="edge">
<title>DOTNETPKG&#45;&gt;ENV_IMG</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M484.38,-529.88C459.31,-518.51 426.58,-503.33 398,-489 381.75,-480.85 364.29,-471.62 348.4,-463.03"/>
<polygon fill="black" stroke="black" points="349.71,-459.76 339.25,-458.06 346.37,-465.91 349.71,-459.76"/>
<text text-anchor="middle" x="460" y="-500.8" font-family="Times,serif" font-size="14.00">install</text>
</g>
<!-- SRC -->
<g id="node6" class="node">
<title>SRC</title>
<polygon fill="royalblue" stroke="black" points="466.5,-449.88 463.5,-453.88 442.5,-453.88 439.5,-449.88 407.5,-449.88 407.5,-413.88 466.5,-413.88 466.5,-449.88"/>
<text text-anchor="middle" x="437" y="-428.18" font-family="Times,serif" font-size="14.00">git repo</text>
</g>
<!-- DEVEL_IMG -->
<g id="node8" class="node">
<title>DEVEL_IMG</title>
<path fill="royalblue" stroke="black" d="M387,-350.1C387,-352.74 345.32,-354.88 294,-354.88 242.68,-354.88 201,-352.74 201,-350.1 201,-350.1 201,-307.15 201,-307.15 201,-304.51 242.68,-302.37 294,-302.37 345.32,-302.37 387,-304.51 387,-307.15 387,-307.15 387,-350.1 387,-350.1"/>
<path fill="none" stroke="black" d="M387,-350.1C387,-347.47 345.32,-345.33 294,-345.33 242.68,-345.33 201,-347.47 201,-350.1"/>
<text text-anchor="middle" x="294" y="-332.43" font-family="Times,serif" font-size="14.00">or&#45;tools/docker:&lt;distro&gt;_devel</text>
<text text-anchor="middle" x="294" y="-317.43" font-family="Times,serif" font-size="14.00">devel</text>
</g>
<!-- SRC&#45;&gt;DEVEL_IMG -->
<g id="edge9" class="edge">
<title>SRC&#45;&gt;DEVEL_IMG</title>
<path fill="none" stroke="black" stroke-dasharray="5,2" d="M414.02,-413.76C410.34,-411.06 406.58,-408.32 403,-405.75 382.01,-390.67 358.52,-374.21 338.74,-360.47"/>
<polygon fill="black" stroke="black" points="340.72,-357.58 330.5,-354.76 336.73,-363.33 340.72,-357.58"/>
<text text-anchor="middle" x="390.5" y="-376.55" font-family="Times,serif" font-size="14.00">copy</text>
</g>
<!-- ENV_IMG&#45;&gt;DEVEL_IMG -->
<g id="edge1" class="edge">
<title>ENV_IMG&#45;&gt;DEVEL_IMG</title>
<path fill="none" stroke="black" d="M294,-405.59C294,-393.38 294,-378.54 294,-365.22"/>
<polygon fill="black" stroke="black" points="297.5,-364.94 294,-354.94 290.5,-364.94 297.5,-364.94"/>
</g>
<!-- TP_IMG -->
<g id="node9" class="node">
<title>TP_IMG</title>
<path fill="royalblue" stroke="black" d="M390.5,-260.85C390.5,-263.49 341.87,-265.63 282,-265.63 222.13,-265.63 173.5,-263.49 173.5,-260.85 173.5,-260.85 173.5,-217.9 173.5,-217.9 173.5,-215.26 222.13,-213.12 282,-213.12 341.87,-213.12 390.5,-215.26 390.5,-217.9 390.5,-217.9 390.5,-260.85 390.5,-260.85"/>
<path fill="none" stroke="black" d="M390.5,-260.85C390.5,-258.22 341.87,-256.08 282,-256.08 222.13,-256.08 173.5,-258.22 173.5,-260.85"/>
<text text-anchor="middle" x="282" y="-243.18" font-family="Times,serif" font-size="14.00">or&#45;tools/docker:&lt;distro&gt;_third_party</text>
<text text-anchor="middle" x="282" y="-228.18" font-family="Times,serif" font-size="14.00">third_party</text>
</g>
<!-- DEVEL_IMG&#45;&gt;TP_IMG -->
<g id="edge2" class="edge">
<title>DEVEL_IMG&#45;&gt;TP_IMG</title>
<path fill="none" stroke="black" d="M290.53,-302.39C289.38,-294.07 288.09,-284.66 286.86,-275.72"/>
<polygon fill="black" stroke="black" points="290.29,-274.98 285.46,-265.55 283.36,-275.94 290.29,-274.98"/>
</g>
<!-- BUILD_IMG -->
<g id="node10" class="node">
<title>BUILD_IMG</title>
<path fill="royalblue" stroke="black" d="M374.5,-171.6C374.5,-174.24 333.04,-176.38 282,-176.38 230.96,-176.38 189.5,-174.24 189.5,-171.6 189.5,-171.6 189.5,-128.65 189.5,-128.65 189.5,-126.01 230.96,-123.87 282,-123.87 333.04,-123.87 374.5,-126.01 374.5,-128.65 374.5,-128.65 374.5,-171.6 374.5,-171.6"/>
<path fill="none" stroke="black" d="M374.5,-171.6C374.5,-168.97 333.04,-166.83 282,-166.83 230.96,-166.83 189.5,-168.97 189.5,-171.6"/>
<text text-anchor="middle" x="282" y="-153.93" font-family="Times,serif" font-size="14.00">or&#45;tools/docker:&lt;distro&gt;_build</text>
<text text-anchor="middle" x="282" y="-138.93" font-family="Times,serif" font-size="14.00">build</text>
</g>
<!-- TP_IMG&#45;&gt;BUILD_IMG -->
<g id="edge3" class="edge">
<title>TP_IMG&#45;&gt;BUILD_IMG</title>
<path fill="none" stroke="black" d="M282,-213.14C282,-204.82 282,-195.41 282,-186.47"/>
<polygon fill="black" stroke="black" points="285.5,-186.3 282,-176.3 278.5,-186.3 285.5,-186.3"/>
</g>
<!-- OR_TAR -->
<g id="node11" class="node">
<title>OR_TAR</title>
<polygon fill="royalblue" stroke="black" points="363.5,-52 176.5,-52 176.5,-16 369.5,-16 369.5,-46 363.5,-52"/>
<polyline fill="none" stroke="black" points="363.5,-52 363.5,-46 "/>
<polyline fill="none" stroke="black" points="369.5,-46 363.5,-46 "/>
<text text-anchor="middle" x="273" y="-30.3" font-family="Times,serif" font-size="14.00">or&#45;tools_&lt;distro&gt;_vX.Y.Z.tar.gz</text>
</g>
<!-- BUILD_IMG&#45;&gt;OR_TAR -->
<g id="edge10" class="edge">
<title>BUILD_IMG&#45;&gt;OR_TAR</title>
<path fill="none" stroke="red" d="M280,-123.8C278.57,-105.57 276.63,-81.01 275.16,-62.34"/>
<polygon fill="red" stroke="red" points="278.63,-61.82 274.35,-52.12 271.65,-62.37 278.63,-61.82"/>
<text text-anchor="middle" x="343" y="-94.8" font-family="Times,serif" font-size="14.00">make &lt;distro&gt;_archive</text>
</g>
<!-- FLATZINC_TAR -->
<g id="node12" class="node">
<title>FLATZINC_TAR</title>
<polygon fill="royalblue" stroke="black" points="622,-52 388,-52 388,-16 628,-16 628,-46 622,-52"/>
<polyline fill="none" stroke="black" points="622,-52 622,-46 "/>
<polyline fill="none" stroke="black" points="628,-46 622,-46 "/>
<text text-anchor="middle" x="508" y="-30.3" font-family="Times,serif" font-size="14.00">or&#45;tools_flatzinc_&lt;distro&gt;_vX.Y.Z.tar.gz</text>
</g>
<!-- BUILD_IMG&#45;&gt;FLATZINC_TAR -->
<g id="edge11" class="edge">
<title>BUILD_IMG&#45;&gt;FLATZINC_TAR</title>
<path fill="none" stroke="red" d="M365.45,-125.45C380.95,-119.88 396.74,-113.38 411,-106 436.19,-92.97 461.97,-73.77 480.61,-58.62"/>
<polygon fill="red" stroke="red" points="482.92,-61.26 488.4,-52.19 478.46,-55.86 482.92,-61.26"/>
<text text-anchor="middle" x="500" y="-94.8" font-family="Times,serif" font-size="14.00">make &lt;distro&gt;_archive</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eux
rm -f ./*.svg ./*.png
for i in *.dot; do
#plantuml -Tpng "$i";
plantuml -Tsvg "$i";
done