Skip to content

Commit f6b6609

Browse files
Updated docker runner documentation according to incoming changes (#3977)
* Updated docker runner documentation according to incoming changes * Runners now support accessing profiles outside conan home * Removed docker. prefix on runner config * Fix typo on docker runner config * Clarify arch and platform on docker runner host profile * More fixes on docker runner docs * Update examples/runners/docker/basic.rst --------- Co-authored-by: Francisco Ramírez <[email protected]>
1 parent 8fefac1 commit f6b6609

File tree

3 files changed

+182
-198
lines changed

3 files changed

+182
-198
lines changed

examples/runners/docker/basic.rst

+140-150
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Now, we need to define two new profiles inside the conan ``profiles`` folder. Re
6868
.. code-block:: text
6969
7070
[settings]
71-
arch=x86_64
7271
build_type=Release
72+
arch=x86_64
7373
compiler=gcc
7474
compiler.cppstd=gnu17
7575
compiler.libcxx=libstdc++11
@@ -81,6 +81,28 @@ Now, we need to define two new profiles inside the conan ``profiles`` folder. Re
8181
dockerfile=</my/runner/folder>/mylib
8282
cache=copy
8383
remove=true
84+
platform=linux/amd64
85+
86+
87+
.. note::
88+
89+
Users are free to configure architecture and platform on the host profile.
90+
Conan docker integration will build and run the image using the specified
91+
platform.
92+
93+
For example, if you are using a Mac Silicon, you can set the platform to
94+
``linux/arm64/v8`` to build the image using the armv8 architecture.
95+
96+
.. code-block:: text
97+
98+
[settings]
99+
arch=armv8
100+
# ...
101+
102+
[runner]
103+
platform=linux/arm64/v8
104+
105+
84106
85107
``docker_example_build`` profile
86108

@@ -118,7 +140,7 @@ Now, it's time to create our library ``mylib`` using our new runner definition.
118140

119141
.. code-block:: bash
120142
121-
$ conan create . --version 0.1 -pr:h docker_example_host -pr:b docker_example_build
143+
$ conan create . -pr:h docker_example_host -pr:b docker_example_build
122144
123145
If we split and analyze the command output, we can see what is happening and where the commands are being executed.
124146

@@ -132,7 +154,7 @@ If we split and analyze the command output, we can see what is happening and whe
132154
mylib/0.1: Copied 1 '.txt' file: CMakeLists.txt
133155
mylib/0.1: Copied 1 '.h' file: mylib.h
134156
mylib/0.1: Copied 1 '.cpp' file: mylib.cpp
135-
mylib/0.1: Exported to cache folder: /Users/davidsanfal/.conan2/p/mylib4abd06a04bdaa/e
157+
mylib/0.1: Exported to cache folder: /Users/<user>/.conan2/p/mylib4abd06a04bdaa/e
136158
mylib/0.1: Exported: mylib/0.1#8760bf5a311f01cc26f3b95428203210 (2024-07-08 12:22:01 UTC)
137159
138160
======== Input profiles ========
@@ -160,14 +182,14 @@ If we split and analyze the command output, we can see what is happening and whe
160182

161183
.. code-block:: bash
162184
163-
**********************************************
164-
* Building the Docker image: my-conan-runner *
165-
**********************************************
166-
185+
Building the Docker image: conan-runner-default
167186
Dockerfile path: '</my/runner/folder>/mylib/Dockerfile'
168187
Docker build context: '</my/runner/folder>/mylib'
169188
170-
Step 1/4 : FROM ubuntu:22.04
189+
Step 1/3 : FROM ubuntu:22.04
190+
191+
---> 97271d29cb79
192+
Step 2/3 : RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential cmake python3 python3-pip python3-venv g++-x86-64-linux-gnu && rm -rf /var/lib/apt/lists/*
171193
172194
...
173195
@@ -179,179 +201,147 @@ If we split and analyze the command output, we can see what is happening and whe
179201

180202
.. code-block:: bash
181203
182-
***********************************************************************************
183-
* Save host cache in: </my/runner/folder>/mylib/.conanrunner/local_cache_save.tgz *
184-
***********************************************************************************
185-
204+
Save host cache in: /Users/<user>/sources/test/mylib/.conanrunner/local_cache_save.tgz
186205
Found 1 pkg/version recipes matching * in local cache
187206
Saving mylib/0.1: mylib4abd06a04bdaa
188207
189208
**4.** Create and initialize the docker container.
190209

191210
.. code-block:: bash
192211
193-
*********************************
194-
* Creating the docker container *
195-
*********************************
196-
197-
*****************************************
198-
* Container conan-runner-docker running *
199-
*****************************************
212+
Creating the docker container
213+
Container conan-runner-docker running
200214
201215
**5.** Check if the container has a conan version with the runner feature.
202216

203217
.. code-block:: bash
204218
205-
*******************************************
206-
* Running in container: "conan --version" *
207-
*******************************************
208-
209-
Conan version 2.5.0
219+
conan-runner-docker | $ conan --version
220+
conan-runner-docker | Conan version 2.12.1
210221
211222
**6.** Initialize the container conan cache using the host copy running ``conan cache restore``.
212223

213224
.. code-block:: bash
214225
215-
***********************************************************************************************************
216-
* Running in container: "conan cache restore "/root/conanrunner/mylib/.conanrunner/local_cache_save.tgz"" *
217-
***********************************************************************************************************
218-
219-
Restore: mylib/0.1 in mylib4abd06a04bdaa
220-
Local Cache
221-
mylib
222-
mylib/0.1
223-
revisions
224-
8760bf5a311f01cc26f3b95428203210 (2024-07-08 12:22:19 UTC)
225-
packages
226-
recipe_folder: mylib4abd06a04bdaa
226+
conan-runner-docker | $ conan cache restore "/root/conanrunner/mylib/.conanrunner/local_cache_save.tgz"
227+
conan-runner-docker | Restore: mylib/0.1 in mylib4abd06a04bdaa
228+
conan-runner-docker | Local Cache
229+
conan-runner-docker | mylib
230+
conan-runner-docker | mylib/0.1
231+
conan-runner-docker | revisions
232+
conan-runner-docker | 8760bf5a311f01cc26f3b95428203210 (2025-01-31 12:34:25 UTC)
233+
conan-runner-docker | packages
234+
conan-runner-docker | recipe_folder: mylib4abd06a04bdaa
227235
228236
**7.** Run the conan create inside the container and build "mylib".
229237

230238
.. code-block:: bash
231239
232-
*********************************************************************************************************************************************************
233-
* Running in container: "conan create /root/conanrunner/mylib --version 0.1 -pr:h docker_example_host -pr:b docker_example_build -f json > create.json" *
234-
*********************************************************************************************************************************************************
235-
236-
237-
======== Exporting recipe to the cache ========
238-
mylib/0.1: Exporting package recipe: /root/conanrunner/mylib/conanfile.py
239-
mylib/0.1: Copied 1 '.py' file: conanfile.py
240-
mylib/0.1: Copied 1 '.txt' file: CMakeLists.txt
241-
mylib/0.1: Copied 1 '.cpp' file: mylib.cpp
242-
mylib/0.1: Copied 1 '.h' file: mylib.h
243-
mylib/0.1: Exported to cache folder: /root/.conan2/p/mylib4abd06a04bdaa/e
244-
mylib/0.1: Exported: mylib/0.1#8760bf5a311f01cc26f3b95428203210 (2024-07-08 12:22:20 UTC)
245-
246-
======== Input profiles ========
247-
Profile host:
248-
[settings]
249-
arch=x86_64
250-
build_type=Release
251-
compiler=gcc
252-
compiler.cppstd=gnu17
253-
compiler.libcxx=libstdc++11
254-
compiler.version=11
255-
os=Linux
256-
257-
Profile build:
258-
[settings]
259-
arch=x86_64
260-
build_type=Release
261-
compiler=gcc
262-
compiler.cppstd=gnu17
263-
compiler.libcxx=libstdc++11
264-
compiler.version=11
265-
os=Linux
266-
267-
268-
======== Computing dependency graph ========
269-
Graph root
270-
cli
271-
Requirements
272-
mylib/0.1#8760bf5a311f01cc26f3b95428203210 - Cache
273-
274-
======== Computing necessary packages ========
275-
mylib/0.1: Forced build from source
276-
Requirements
277-
mylib/0.1#8760bf5a311f01cc26f3b95428203210:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe - Build
278-
279-
======== Installing packages ========
280-
281-
-------- Installing package mylib/0.1 (1 of 1) --------
282-
240+
conan-runner-docker | $ conan create /root/conanrunner/mylib -pr:h docker_param_example_host -pr:b docker_param_example_build
241+
-f json > create.json
242+
conan-runner-docker |
243+
conan-runner-docker | ======== Exporting recipe to the cache ========
244+
conan-runner-docker | mylib/0.1: Exporting package recipe: /root/conanrunner/mylib/conanfile.py
245+
conan-runner-docker | mylib/0.1: Copied 1 '.py' file: conanfile.py
246+
conan-runner-docker | mylib/0.1: Copied 1 '.txt' file: CMakeLists.txt
247+
conan-runner-docker | mylib/0.1: Copied 1 '.h' file: mylib.h
248+
conan-runner-docker | mylib/0.1: Copied 1 '.cpp' file: mylib.cpp
249+
conan-runner-docker | mylib/0.1: Exported to cache folder: /root/.conan2/p/mylib4abd06a04bdaa/e
250+
conan-runner-docker | mylib/0.1: Exported: mylib/0.1#8760bf5a311f01cc26f3b95428203210 (2025-01-31 12:34:26 UTC)
251+
conan-runner-docker |
252+
conan-runner-docker | ======== Input profiles ========
253+
conan-runner-docker | Profile host:
254+
conan-runner-docker | [settings]
255+
conan-runner-docker | arch=x86_64
256+
conan-runner-docker | build_type=Release
257+
conan-runner-docker | compiler=gcc
258+
conan-runner-docker | compiler.cppstd=gnu17
259+
conan-runner-docker | compiler.libcxx=libstdc++11
260+
conan-runner-docker | compiler.version=11
261+
conan-runner-docker | os=Linux
262+
conan-runner-docker |
263+
conan-runner-docker | Profile build:
264+
conan-runner-docker | [settings]
265+
conan-runner-docker | arch=x86_64
266+
conan-runner-docker | build_type=Release
267+
conan-runner-docker | compiler=gcc
268+
conan-runner-docker | compiler.cppstd=gnu17
269+
conan-runner-docker | compiler.libcxx=libstdc++11
270+
conan-runner-docker | compiler.version=11
271+
conan-runner-docker | os=Linux
272+
conan-runner-docker |
273+
conan-runner-docker |
274+
conan-runner-docker | ======== Computing dependency graph ========
275+
conan-runner-docker | Graph root
276+
conan-runner-docker | cli
277+
conan-runner-docker | Requirements
278+
conan-runner-docker | mylib/0.1#8760bf5a311f01cc26f3b95428203210 - Cache
279+
conan-runner-docker |
280+
conan-runner-docker | ======== Computing necessary packages ========
281+
conan-runner-docker | mylib/0.1: Forced build from source
282+
conan-runner-docker | Requirements
283+
conan-runner-docker | mylib/0.1#8760bf5a311f01cc26f3b95428203210:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe - Build
284+
conan-runner-docker |
283285
284286
...
285-
286-
[ 50%] Building CXX object CMakeFiles/example.dir/src/example.cpp.o
287-
[100%] Linking CXX executable example
288-
[100%] Built target example
287+
288+
conan-runner-docker | [ 50%] Building CXX object CMakeFiles/example.dir/src/example.cpp.o
289+
conan-runner-docker | [100%] Linking CXX executable example
290+
conan-runner-docker | [100%] Built target example
291+
conan-runner-docker |
292+
conan-runner-docker |
293+
conan-runner-docker | ======== Testing the package: Executing test ========
294+
conan-runner-docker | mylib/0.1 (test package): Running test()
295+
conan-runner-docker | mylib/0.1 (test package): RUN: ./example
296+
conan-runner-docker | mylib/0.1: Hello World Release!
297+
conan-runner-docker | mylib/0.1: __x86_64__ defined
298+
conan-runner-docker | mylib/0.1: _GLIBCXX_USE_CXX11_ABI 1
299+
conan-runner-docker | mylib/0.1: __cplusplus201703
300+
conan-runner-docker | mylib/0.1: __GNUC__11
301+
conan-runner-docker | mylib/0.1: __GNUC_MINOR__4
302+
conan-runner-docker | mylib/0.1 test_package
289303
290304
291-
======== Testing the package: Executing test ========
292-
mylib/0.1 (test package): Running test()
293-
mylib/0.1 (test package): RUN: ./example
294-
mylib/0.1: Hello World Release!
295-
mylib/0.1: __x86_64__ defined
296-
mylib/0.1: _GLIBCXX_USE_CXX11_ABI 1
297-
mylib/0.1: __cplusplus201703
298-
mylib/0.1: __GNUC__11
299-
mylib/0.1: __GNUC_MINOR__4
300-
mylib/0.1 test_package
301-
302305
**8.** Copy just the package created inside the container using the ``pkglist.json`` info from the previous ``conan create``, restore this new package inside the host cache running a ``conan cache save`` and remove the container.
303306

304307
.. code-block:: bash
305308
306-
************************************************************************************************************************************
307-
* Running in container: "conan cache save --list=pkglist.json --file "/root/conanrunner/mylib"/.conanrunner/docker_cache_save.tgz" *
308-
************************************************************************************************************************************
309-
310-
Saving mylib/0.1: mylib4abd06a04bdaa
311-
Saving mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe: b/mylib503035e4ee8ae/p
312-
Saving mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata: b/mylib503035e4ee8ae/d/metadata
313-
Local Cache
314-
mylib
315-
mylib/0.1
316-
revisions
317-
8760bf5a311f01cc26f3b95428203210 (2024-07-08 12:22:20 UTC)
318-
packages
319-
8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe
320-
revisions
321-
ded6547554ff2306db5250451340fa43
322-
package_folder: b/mylib503035e4ee8ae/p
323-
metadata_folder: b/mylib503035e4ee8ae/d/metadata
324-
info
325-
settings
326-
os: Linux
327-
arch: x86_64
328-
compiler: gcc
329-
compiler.cppstd: gnu17
330-
compiler.libcxx: libstdc++11
331-
compiler.version: 11
332-
build_type: Release
333-
options
334-
fPIC: True
335-
shared: False
336-
recipe_folder: mylib4abd06a04bdaa
337-
338-
339-
******************************************************************************************
340-
* Restore host cache from: </my/runner/folder>/mylib/.conanrunner/docker_cache_save.tgz *
341-
******************************************************************************************
342-
309+
conan-runner-docker | $ conan cache save --list=pkglist.json --file "/root/conanrunner/mylib"/.conanrunner/docker_cache_save.tgz
310+
conan-runner-docker | Saving mylib/0.1: mylib4abd06a04bdaa
311+
conan-runner-docker | Saving mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe: b/mylib11242e0a7e627/p
312+
conan-runner-docker | Saving mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata: b/mylib11242e0a7e627/d/metadata
313+
conan-runner-docker | Local Cache
314+
conan-runner-docker | mylib
315+
conan-runner-docker | mylib/0.1
316+
conan-runner-docker | revisions
317+
conan-runner-docker | 8760bf5a311f01cc26f3b95428203210 (2025-01-31 12:34:26 UTC)
318+
conan-runner-docker | packages
319+
conan-runner-docker | 8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe
320+
conan-runner-docker | revisions
321+
conan-runner-docker | ded6547554ff2306db5250451340fa43
322+
conan-runner-docker | package_folder: b/mylib11242e0a7e627/p
323+
conan-runner-docker | metadata_folder: b/mylib11242e0a7e627/d/metadata
324+
conan-runner-docker | info
325+
conan-runner-docker | settings
326+
conan-runner-docker | os: Linux
327+
conan-runner-docker | arch: x86_64
328+
conan-runner-docker | compiler: gcc
329+
conan-runner-docker | compiler.cppstd: gnu17
330+
conan-runner-docker | compiler.libcxx: libstdc++11
331+
conan-runner-docker | compiler.version: 11
332+
conan-runner-docker | build_type: Release
333+
conan-runner-docker | options
334+
conan-runner-docker | fPIC: True
335+
conan-runner-docker | shared: False
336+
conan-runner-docker | recipe_folder: mylib4abd06a04bdaa
337+
conan-runner-docker |
338+
Restore host cache from: /Users/<user>/sources/test/mylib/.conanrunner/docker_cache_save.tgz
343339
Restore: mylib/0.1 in mylib4abd06a04bdaa
344-
Restore: mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe in b/mylib503035e4ee8ae/p
345-
Restore: mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata in b/mylib503035e4ee8ae/d/metadata
346-
347-
**********************
348-
* Stopping container *
349-
**********************
350-
340+
Restore: mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe in b/mylib11242e0a7e627/p
341+
Restore: mylib/0.1:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata in b/mylib11242e0a7e627/d/metadata
342+
Stopping container
343+
Removing container
351344
352-
**********************
353-
* Removing container *
354-
**********************
355345
356346
If we now check the status of our conan and docker cache, we will see the new mylib package compile for Linux and the new docker image but we don’t have any container because we define ``remove=true``
357347

@@ -392,4 +382,4 @@ If we now check the status of our conan and docker cache, we will see the new my
392382
393383
What we have just done is to compile a library from scratch inside a Docker container without running any Docker command and retrieve the generated packages in a totally transparent and easily debuggable way thanks to our terminal output.
394384

395-
In this way, we can work as we have always done regardless of whether it is on our machine or in a container, without several open terminals and having the result of each operation in the same cache, being able to reuse the compiled packages from a previous compilation in another container automatically and transparently.
385+
In this way, we can work as we have always done regardless of whether it is on our machine or in a container, without several open terminals and having the result of each operation in the same cache, being able to reuse the compiled packages from a previous compilation in another container automatically and transparently.

0 commit comments

Comments
 (0)