Debian Codegraph @

dockerfiles/README.rst

raw
1 Labgrid Docker images
2 =====================
3
4 This folder contains Dockerfile's for building Docker images
5 for the 3 different components of a Labgrid distributed infrastructure.
6
7 - **labgrid-coordinator**
8 An image with the Labgrid coordinator.
9 a Labgrid coordinator instance.
10 - **labgrid-coordinator-statsd**
11 An image with a statsd reporter for the Labgrid coordinator.
12 - **labgrid-client**
13 An image with the Labgrid client tools and pytest integration.
14 - **labgrid-exporter**
15 An image with the Labgrid exporter tools.
16
17
18 Build
19 -----
20
21 To build one of the above images,
22 you need to run the ``docker build`` command in the root of this repository.
23 Example showing how to build labgrid-client image:
24
25 .. code-block:: bash
26
27 $ docker build --target labgrid-client -t docker.io/labgrid/client -f dockerfiles/Dockerfile .
28
29 Using `BuildKit <https://docs.docker.com/develop/develop-images/build_enhancements/>`_
30 is recommended to reduce build times.
31
32 You can also choose to build all images with the included script. The script
33 will automatically use `docker buildx
34 <https://docs.docker.com/engine/reference/commandline/buildx/>`` if available.
35
36 .. code-block:: bash
37
38 $ pip install --upgrade setuptools_scm
39 $ ./dockerfiles/build.sh
40
41 The script supports ``podman`` as well.
42
43 .. code-block:: bash
44 $ export DOCKER=podman
45 $ ./dockerfiles/build.sh
46
47 It builds for the native platform by default. However, building
48 for foreign platforms is also supported by passing the platform(s) of choice,
49 e.g. `linux/arm64` as an additional argument.
50
51 .. code-block:: bash
52
53 $ pip install --upgrade setuptools_scm
54 $ ./dockerfiles/build.sh --platform linux/arm64
55
56
57 Usage
58 -----
59
60 All 3 images are to be considered base images
61 with the required software installed.
62 No policy or configuration is done.
63
64
65 labgrid-coordinator usage
66 ~~~~~~~~~~~~~~~~~~~~~~~~~
67
68 The labgrid-coordinator image can be used to run a coordinator instance.
69
70 It listens on port 20408,
71 so you probably want to publish that so you can talk to the coordinator.
72
73 State is written to ``/opt/coordinator``.
74 You might want to bind a volume to that
75 so you can restart the service without losing state.
76
77 .. code-block:: bash
78
79 $ docker run -t -p 20408:20408 -v $HOME/coordinator:/opt/coordinator \
80 docker.io/labgrid/coordinator
81
82
83 labgrid-coordinator-statsd usage
84 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85
86 The labgrid-coordinator-statsd image can be used to run a statsd reporter for the coordinator.
87
88 The address of the statsd server and other options can be configured using parameters as passed to the ``contrib/coordinator-statsd.py`` script.
89 For example, to run the statsd reporter with a coordinator at 192.168.1.42:20408:
90
91 .. code-block:: bash
92
93 $ docker run -e LG_COORDINATOR=192.168.1.42:20408 docker.io/labgrid/coordinator-statsd \
94 --statsd-server=192.168.1.50
95
96
97 labgrid-client usage
98 ~~~~~~~~~~~~~~~~~~~~
99
100 The labgrid-client image can be used to
101 run ``labgrid-client`` and ``pytest`` commands.
102 For example listing available places registered at coordinator at
103 192.168.1.42:20408
104
105 .. code-block:: bash
106
107 $ docker run -e LG_COORDINATOR=192.168.1.42:20408 docker.io/labgrid/client \
108 labgrid-client places
109
110 Or running all pytest/labgrid tests at current directory:
111
112 .. code-block:: bash
113
114 $ docker run -e LG_COORDINATOR=192.168.1.42:20408 docker.io/labgrid/client \
115 pytest
116
117
118 labgrid-exporter usage
119 ~~~~~~~~~~~~~~~~~~~~~~
120
121 The labgrid-exporter image runs a labgrid-exporter
122 and optionally an ser2net service.
123
124 Configuration is not included, but needs to be bind mounted to
125 /opt/conf/exporter.yaml and /opt/conf/ser2net.conf (optional).
126
127 Start it with something like:
128
129 .. code-block:: bash
130
131 $ docker run -e LG_COORDINATOR=192.168.1.42:20408 \
132 -v $HOME/exporter-conf:/opt/conf \
133 docker.io/labgrid/exporter
134
135 If using ser2net or if "exporting" e.g. a serial device, the devices needed must be added to Docker container
136 (``docker run --device`` option).
137 Moreover, if using udev this must be mounted in as well: ``docker run -v run/udev:/run/udev:ro``.
138
139 Staging
140 -------
141
142 The ``staging`` folder contains a docker compose based example setup, where the images described above are used to
143 create a setup with the following instances
144
145 - **coordinator**
146 - **exporter**
147 - **client**
148 - **dut**
149
150 The environment serves both to allow checking if the environment still function after changes, and can act as an example
151 how to configure the docker images needed to run a minimal setup.
152
153 To use the staging environment to conduct a smoke test, first run docker compose to start all services except the
154 client:
155
156 .. code-block:: bash
157
158 $ cd dockerfiles/staging
159 $ CURRENT_UID=$(id -u):$(id -g) docker compose up -d coordinator coordinator-statsd exporter dut
160
161 To run the smoke test just run the client:
162
163 .. code-block:: bash
164
165 $ docker compose up client