@@ -68,8 +68,8 @@ Now, we need to define two new profiles inside the conan ``profiles`` folder. Re
68
68
.. code-block :: text
69
69
70
70
[settings]
71
- arch=x86_64
72
71
build_type=Release
72
+ arch=x86_64
73
73
compiler=gcc
74
74
compiler.cppstd=gnu17
75
75
compiler.libcxx=libstdc++11
@@ -81,6 +81,28 @@ Now, we need to define two new profiles inside the conan ``profiles`` folder. Re
81
81
dockerfile=</my/runner/folder>/mylib
82
82
cache=copy
83
83
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
+
84
106
85
107
``docker_example_build `` profile
86
108
@@ -118,7 +140,7 @@ Now, it's time to create our library ``mylib`` using our new runner definition.
118
140
119
141
.. code-block :: bash
120
142
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
122
144
123
145
If we split and analyze the command output, we can see what is happening and where the commands are being executed.
124
146
@@ -132,7 +154,7 @@ If we split and analyze the command output, we can see what is happening and whe
132
154
mylib/0.1: Copied 1 ' .txt' file: CMakeLists.txt
133
155
mylib/0.1: Copied 1 ' .h' file: mylib.h
134
156
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
136
158
mylib/0.1: Exported: mylib/0.1#8760bf5a311f01cc26f3b95428203210 (2024-07-08 12:22:01 UTC)
137
159
138
160
======== Input profiles ========
@@ -160,14 +182,14 @@ If we split and analyze the command output, we can see what is happening and whe
160
182
161
183
.. code-block :: bash
162
184
163
- **********************************************
164
- * Building the Docker image: my-conan-runner *
165
- **********************************************
166
-
185
+ Building the Docker image: conan-runner-default
167
186
Dockerfile path: ' </my/runner/folder>/mylib/Dockerfile'
168
187
Docker build context: ' </my/runner/folder>/mylib'
169
188
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/*
171
193
172
194
...
173
195
@@ -179,179 +201,147 @@ If we split and analyze the command output, we can see what is happening and whe
179
201
180
202
.. code-block :: bash
181
203
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
186
205
Found 1 pkg/version recipes matching * in local cache
187
206
Saving mylib/0.1: mylib4abd06a04bdaa
188
207
189
208
**4. ** Create and initialize the docker container.
190
209
191
210
.. code-block :: bash
192
211
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
200
214
201
215
**5. ** Check if the container has a conan version with the runner feature.
202
216
203
217
.. code-block :: bash
204
218
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
210
221
211
222
**6. ** Initialize the container conan cache using the host copy running ``conan cache restore ``.
212
223
213
224
.. code-block :: bash
214
225
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
227
235
228
236
**7. ** Run the conan create inside the container and build "mylib".
229
237
230
238
.. code-block :: bash
231
239
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 |
283
285
284
286
...
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
289
303
290
304
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
-
302
305
**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.
303
306
304
307
.. code-block :: bash
305
308
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
343
339
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
351
344
352
- **********************
353
- * Removing container *
354
- **********************
355
345
356
346
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 ``
357
347
@@ -392,4 +382,4 @@ If we now check the status of our conan and docker cache, we will see the new my
392
382
393
383
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.
394
384
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