pulumi-docker 4.6.0b2__py3-none-any.whl → 4.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pulumi-docker might be problematic. Click here for more details.

@@ -1,1638 +0,0 @@
1
- # coding=utf-8
2
- # *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
3
- # *** Do not edit by hand unless you're certain you know what you are doing! ***
4
-
5
- import copy
6
- import warnings
7
- import pulumi
8
- import pulumi.runtime
9
- from typing import Any, Mapping, Optional, Sequence, Union, overload
10
- from .. import _utilities
11
- from . import outputs
12
- from ._enums import *
13
- from ._inputs import *
14
-
15
- __all__ = ['ImageArgs', 'Image']
16
-
17
- @pulumi.input_type
18
- class ImageArgs:
19
- def __init__(__self__, *,
20
- add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
21
- build_args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
22
- build_on_preview: Optional[pulumi.Input[bool]] = None,
23
- builder: Optional[pulumi.Input['BuilderConfigArgs']] = None,
24
- cache_from: Optional[pulumi.Input[Sequence[pulumi.Input['CacheFromEntryArgs']]]] = None,
25
- cache_to: Optional[pulumi.Input[Sequence[pulumi.Input['CacheToEntryArgs']]]] = None,
26
- context: Optional[pulumi.Input['BuildContextArgs']] = None,
27
- dockerfile: Optional[pulumi.Input['DockerfileArgs']] = None,
28
- exports: Optional[pulumi.Input[Sequence[pulumi.Input['ExportEntryArgs']]]] = None,
29
- labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
30
- load: Optional[pulumi.Input[bool]] = None,
31
- network: Optional[pulumi.Input['NetworkMode']] = None,
32
- no_cache: Optional[pulumi.Input[bool]] = None,
33
- platforms: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]] = None,
34
- pull: Optional[pulumi.Input[bool]] = None,
35
- push: Optional[pulumi.Input[bool]] = None,
36
- registries: Optional[pulumi.Input[Sequence[pulumi.Input['RegistryAuthArgs']]]] = None,
37
- secrets: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
38
- ssh: Optional[pulumi.Input[Sequence[pulumi.Input['SSHArgs']]]] = None,
39
- tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
40
- targets: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None):
41
- """
42
- The set of arguments for constructing a Image resource.
43
- :param pulumi.Input[Sequence[pulumi.Input[str]]] add_hosts: Custom `host:ip` mappings to use during the build.
44
-
45
- Equivalent to Docker's `--add-host` flag.
46
- :param pulumi.Input[Mapping[str, pulumi.Input[str]]] build_args: `ARG` names and values to set during the build.
47
-
48
- These variables are accessed like environment variables inside `RUN`
49
- instructions.
50
-
51
- Build arguments are persisted in the image, so you should use `secrets`
52
- if these arguments are sensitive.
53
-
54
- Equivalent to Docker's `--build-arg` flag.
55
- :param pulumi.Input[bool] build_on_preview: By default, preview behavior depends on the execution environment. If
56
- Pulumi detects the operation is running on a CI system (GitHub Actions,
57
- Travis CI, Azure Pipelines, etc.) then it will build images during
58
- previews as a safeguard. Otherwise, if not running on CI, previews will
59
- not build images.
60
-
61
- Setting this to `false` forces previews to never perform builds, and
62
- setting it to `true` will always build the image during previews.
63
-
64
- Images built during previews are never exported to registries, however
65
- cache manifests are still exported.
66
-
67
- On-disk Dockerfiles are always validated for syntactic correctness
68
- regardless of this setting.
69
- :param pulumi.Input['BuilderConfigArgs'] builder: Builder configuration.
70
- :param pulumi.Input[Sequence[pulumi.Input['CacheFromEntryArgs']]] cache_from: Cache export configuration.
71
-
72
- Equivalent to Docker's `--cache-from` flag.
73
- :param pulumi.Input[Sequence[pulumi.Input['CacheToEntryArgs']]] cache_to: Cache import configuration.
74
-
75
- Equivalent to Docker's `--cache-to` flag.
76
- :param pulumi.Input['BuildContextArgs'] context: Build context settings.
77
-
78
- Equivalent to Docker's `PATH | URL | -` positional argument.
79
- :param pulumi.Input['DockerfileArgs'] dockerfile: Dockerfile settings.
80
-
81
- Equivalent to Docker's `--file` flag.
82
- :param pulumi.Input[Sequence[pulumi.Input['ExportEntryArgs']]] exports: Controls where images are persisted after building.
83
-
84
- Images are only stored in the local cache unless `exports` are
85
- explicitly configured.
86
-
87
- Equivalent to Docker's `--output` flag.
88
- :param pulumi.Input[Mapping[str, pulumi.Input[str]]] labels: Attach arbitrary key/value metadata to the image.
89
-
90
- Equivalent to Docker's `--label` flag.
91
- :param pulumi.Input[bool] load: When `true` the build will automatically include a `docker` export.
92
-
93
- Defaults to `false`.
94
-
95
- Equivalent to Docker's `--load` flag.
96
- :param pulumi.Input['NetworkMode'] network: Set the network mode for `RUN` instructions. Defaults to `default`.
97
-
98
- For custom networks, configure your builder with `--driver-opt network=...`.
99
-
100
- Equivalent to Docker's `--network` flag.
101
- :param pulumi.Input[bool] no_cache: Do not import cache manifests when building the image.
102
-
103
- Equivalent to Docker's `--no-cache` flag.
104
- :param pulumi.Input[Sequence[pulumi.Input['Platform']]] platforms: Set target platform(s) for the build. Defaults to the host's platform.
105
-
106
- Equivalent to Docker's `--platform` flag.
107
- :param pulumi.Input[bool] pull: Always pull referenced images.
108
-
109
- Equivalent to Docker's `--pull` flag.
110
- :param pulumi.Input[bool] push: When `true` the build will automatically include a `registry` export.
111
-
112
- Defaults to `false`.
113
-
114
- Equivalent to Docker's `--push` flag.
115
- :param pulumi.Input[Sequence[pulumi.Input['RegistryAuthArgs']]] registries: Registry credentials. Required if reading or exporting to private
116
- repositories.
117
-
118
- Credentials are kept in-memory and do not pollute pre-existing
119
- credentials on the host.
120
-
121
- Similar to `docker login`.
122
- :param pulumi.Input[Mapping[str, pulumi.Input[str]]] secrets: A mapping of secret names to their corresponding values.
123
-
124
- Unlike the Docker CLI, these can be passed by value and do not need to
125
- exist on-disk or in environment variables.
126
-
127
- Build arguments and environment variables are persistent in the final
128
- image, so you should use this for sensitive values.
129
-
130
- Similar to Docker's `--secret` flag.
131
- :param pulumi.Input[Sequence[pulumi.Input['SSHArgs']]] ssh: SSH agent socket or keys to expose to the build.
132
-
133
- Equivalent to Docker's `--ssh` flag.
134
- :param pulumi.Input[Sequence[pulumi.Input[str]]] tags: Name and optionally a tag (format: `name:tag`).
135
-
136
- If exporting to a registry, the name should include the fully qualified
137
- registry address (e.g. `docker.io/pulumi/pulumi:latest`).
138
-
139
- Equivalent to Docker's `--tag` flag.
140
- :param pulumi.Input[Sequence[pulumi.Input[str]]] targets: Set the target build stage(s) to build.
141
-
142
- If not specified all targets will be built by default.
143
-
144
- Equivalent to Docker's `--target` flag.
145
- """
146
- if add_hosts is not None:
147
- pulumi.set(__self__, "add_hosts", add_hosts)
148
- if build_args is not None:
149
- pulumi.set(__self__, "build_args", build_args)
150
- if build_on_preview is not None:
151
- pulumi.set(__self__, "build_on_preview", build_on_preview)
152
- if builder is not None:
153
- pulumi.set(__self__, "builder", builder)
154
- if cache_from is not None:
155
- pulumi.set(__self__, "cache_from", cache_from)
156
- if cache_to is not None:
157
- pulumi.set(__self__, "cache_to", cache_to)
158
- if context is not None:
159
- pulumi.set(__self__, "context", context)
160
- if dockerfile is not None:
161
- pulumi.set(__self__, "dockerfile", dockerfile)
162
- if exports is not None:
163
- pulumi.set(__self__, "exports", exports)
164
- if labels is not None:
165
- pulumi.set(__self__, "labels", labels)
166
- if load is not None:
167
- pulumi.set(__self__, "load", load)
168
- if network is None:
169
- network = 'default'
170
- if network is not None:
171
- pulumi.set(__self__, "network", network)
172
- if no_cache is not None:
173
- pulumi.set(__self__, "no_cache", no_cache)
174
- if platforms is not None:
175
- pulumi.set(__self__, "platforms", platforms)
176
- if pull is not None:
177
- pulumi.set(__self__, "pull", pull)
178
- if push is not None:
179
- pulumi.set(__self__, "push", push)
180
- if registries is not None:
181
- pulumi.set(__self__, "registries", registries)
182
- if secrets is not None:
183
- pulumi.set(__self__, "secrets", secrets)
184
- if ssh is not None:
185
- pulumi.set(__self__, "ssh", ssh)
186
- if tags is not None:
187
- pulumi.set(__self__, "tags", tags)
188
- if targets is not None:
189
- pulumi.set(__self__, "targets", targets)
190
-
191
- @property
192
- @pulumi.getter(name="addHosts")
193
- def add_hosts(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
194
- """
195
- Custom `host:ip` mappings to use during the build.
196
-
197
- Equivalent to Docker's `--add-host` flag.
198
- """
199
- return pulumi.get(self, "add_hosts")
200
-
201
- @add_hosts.setter
202
- def add_hosts(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
203
- pulumi.set(self, "add_hosts", value)
204
-
205
- @property
206
- @pulumi.getter(name="buildArgs")
207
- def build_args(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
208
- """
209
- `ARG` names and values to set during the build.
210
-
211
- These variables are accessed like environment variables inside `RUN`
212
- instructions.
213
-
214
- Build arguments are persisted in the image, so you should use `secrets`
215
- if these arguments are sensitive.
216
-
217
- Equivalent to Docker's `--build-arg` flag.
218
- """
219
- return pulumi.get(self, "build_args")
220
-
221
- @build_args.setter
222
- def build_args(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):
223
- pulumi.set(self, "build_args", value)
224
-
225
- @property
226
- @pulumi.getter(name="buildOnPreview")
227
- def build_on_preview(self) -> Optional[pulumi.Input[bool]]:
228
- """
229
- By default, preview behavior depends on the execution environment. If
230
- Pulumi detects the operation is running on a CI system (GitHub Actions,
231
- Travis CI, Azure Pipelines, etc.) then it will build images during
232
- previews as a safeguard. Otherwise, if not running on CI, previews will
233
- not build images.
234
-
235
- Setting this to `false` forces previews to never perform builds, and
236
- setting it to `true` will always build the image during previews.
237
-
238
- Images built during previews are never exported to registries, however
239
- cache manifests are still exported.
240
-
241
- On-disk Dockerfiles are always validated for syntactic correctness
242
- regardless of this setting.
243
- """
244
- return pulumi.get(self, "build_on_preview")
245
-
246
- @build_on_preview.setter
247
- def build_on_preview(self, value: Optional[pulumi.Input[bool]]):
248
- pulumi.set(self, "build_on_preview", value)
249
-
250
- @property
251
- @pulumi.getter
252
- def builder(self) -> Optional[pulumi.Input['BuilderConfigArgs']]:
253
- """
254
- Builder configuration.
255
- """
256
- return pulumi.get(self, "builder")
257
-
258
- @builder.setter
259
- def builder(self, value: Optional[pulumi.Input['BuilderConfigArgs']]):
260
- pulumi.set(self, "builder", value)
261
-
262
- @property
263
- @pulumi.getter(name="cacheFrom")
264
- def cache_from(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['CacheFromEntryArgs']]]]:
265
- """
266
- Cache export configuration.
267
-
268
- Equivalent to Docker's `--cache-from` flag.
269
- """
270
- return pulumi.get(self, "cache_from")
271
-
272
- @cache_from.setter
273
- def cache_from(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['CacheFromEntryArgs']]]]):
274
- pulumi.set(self, "cache_from", value)
275
-
276
- @property
277
- @pulumi.getter(name="cacheTo")
278
- def cache_to(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['CacheToEntryArgs']]]]:
279
- """
280
- Cache import configuration.
281
-
282
- Equivalent to Docker's `--cache-to` flag.
283
- """
284
- return pulumi.get(self, "cache_to")
285
-
286
- @cache_to.setter
287
- def cache_to(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['CacheToEntryArgs']]]]):
288
- pulumi.set(self, "cache_to", value)
289
-
290
- @property
291
- @pulumi.getter
292
- def context(self) -> Optional[pulumi.Input['BuildContextArgs']]:
293
- """
294
- Build context settings.
295
-
296
- Equivalent to Docker's `PATH | URL | -` positional argument.
297
- """
298
- return pulumi.get(self, "context")
299
-
300
- @context.setter
301
- def context(self, value: Optional[pulumi.Input['BuildContextArgs']]):
302
- pulumi.set(self, "context", value)
303
-
304
- @property
305
- @pulumi.getter
306
- def dockerfile(self) -> Optional[pulumi.Input['DockerfileArgs']]:
307
- """
308
- Dockerfile settings.
309
-
310
- Equivalent to Docker's `--file` flag.
311
- """
312
- return pulumi.get(self, "dockerfile")
313
-
314
- @dockerfile.setter
315
- def dockerfile(self, value: Optional[pulumi.Input['DockerfileArgs']]):
316
- pulumi.set(self, "dockerfile", value)
317
-
318
- @property
319
- @pulumi.getter
320
- def exports(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ExportEntryArgs']]]]:
321
- """
322
- Controls where images are persisted after building.
323
-
324
- Images are only stored in the local cache unless `exports` are
325
- explicitly configured.
326
-
327
- Equivalent to Docker's `--output` flag.
328
- """
329
- return pulumi.get(self, "exports")
330
-
331
- @exports.setter
332
- def exports(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['ExportEntryArgs']]]]):
333
- pulumi.set(self, "exports", value)
334
-
335
- @property
336
- @pulumi.getter
337
- def labels(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
338
- """
339
- Attach arbitrary key/value metadata to the image.
340
-
341
- Equivalent to Docker's `--label` flag.
342
- """
343
- return pulumi.get(self, "labels")
344
-
345
- @labels.setter
346
- def labels(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):
347
- pulumi.set(self, "labels", value)
348
-
349
- @property
350
- @pulumi.getter
351
- def load(self) -> Optional[pulumi.Input[bool]]:
352
- """
353
- When `true` the build will automatically include a `docker` export.
354
-
355
- Defaults to `false`.
356
-
357
- Equivalent to Docker's `--load` flag.
358
- """
359
- return pulumi.get(self, "load")
360
-
361
- @load.setter
362
- def load(self, value: Optional[pulumi.Input[bool]]):
363
- pulumi.set(self, "load", value)
364
-
365
- @property
366
- @pulumi.getter
367
- def network(self) -> Optional[pulumi.Input['NetworkMode']]:
368
- """
369
- Set the network mode for `RUN` instructions. Defaults to `default`.
370
-
371
- For custom networks, configure your builder with `--driver-opt network=...`.
372
-
373
- Equivalent to Docker's `--network` flag.
374
- """
375
- return pulumi.get(self, "network")
376
-
377
- @network.setter
378
- def network(self, value: Optional[pulumi.Input['NetworkMode']]):
379
- pulumi.set(self, "network", value)
380
-
381
- @property
382
- @pulumi.getter(name="noCache")
383
- def no_cache(self) -> Optional[pulumi.Input[bool]]:
384
- """
385
- Do not import cache manifests when building the image.
386
-
387
- Equivalent to Docker's `--no-cache` flag.
388
- """
389
- return pulumi.get(self, "no_cache")
390
-
391
- @no_cache.setter
392
- def no_cache(self, value: Optional[pulumi.Input[bool]]):
393
- pulumi.set(self, "no_cache", value)
394
-
395
- @property
396
- @pulumi.getter
397
- def platforms(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]]:
398
- """
399
- Set target platform(s) for the build. Defaults to the host's platform.
400
-
401
- Equivalent to Docker's `--platform` flag.
402
- """
403
- return pulumi.get(self, "platforms")
404
-
405
- @platforms.setter
406
- def platforms(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]]):
407
- pulumi.set(self, "platforms", value)
408
-
409
- @property
410
- @pulumi.getter
411
- def pull(self) -> Optional[pulumi.Input[bool]]:
412
- """
413
- Always pull referenced images.
414
-
415
- Equivalent to Docker's `--pull` flag.
416
- """
417
- return pulumi.get(self, "pull")
418
-
419
- @pull.setter
420
- def pull(self, value: Optional[pulumi.Input[bool]]):
421
- pulumi.set(self, "pull", value)
422
-
423
- @property
424
- @pulumi.getter
425
- def push(self) -> Optional[pulumi.Input[bool]]:
426
- """
427
- When `true` the build will automatically include a `registry` export.
428
-
429
- Defaults to `false`.
430
-
431
- Equivalent to Docker's `--push` flag.
432
- """
433
- return pulumi.get(self, "push")
434
-
435
- @push.setter
436
- def push(self, value: Optional[pulumi.Input[bool]]):
437
- pulumi.set(self, "push", value)
438
-
439
- @property
440
- @pulumi.getter
441
- def registries(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['RegistryAuthArgs']]]]:
442
- """
443
- Registry credentials. Required if reading or exporting to private
444
- repositories.
445
-
446
- Credentials are kept in-memory and do not pollute pre-existing
447
- credentials on the host.
448
-
449
- Similar to `docker login`.
450
- """
451
- return pulumi.get(self, "registries")
452
-
453
- @registries.setter
454
- def registries(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['RegistryAuthArgs']]]]):
455
- pulumi.set(self, "registries", value)
456
-
457
- @property
458
- @pulumi.getter
459
- def secrets(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
460
- """
461
- A mapping of secret names to their corresponding values.
462
-
463
- Unlike the Docker CLI, these can be passed by value and do not need to
464
- exist on-disk or in environment variables.
465
-
466
- Build arguments and environment variables are persistent in the final
467
- image, so you should use this for sensitive values.
468
-
469
- Similar to Docker's `--secret` flag.
470
- """
471
- return pulumi.get(self, "secrets")
472
-
473
- @secrets.setter
474
- def secrets(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):
475
- pulumi.set(self, "secrets", value)
476
-
477
- @property
478
- @pulumi.getter
479
- def ssh(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['SSHArgs']]]]:
480
- """
481
- SSH agent socket or keys to expose to the build.
482
-
483
- Equivalent to Docker's `--ssh` flag.
484
- """
485
- return pulumi.get(self, "ssh")
486
-
487
- @ssh.setter
488
- def ssh(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['SSHArgs']]]]):
489
- pulumi.set(self, "ssh", value)
490
-
491
- @property
492
- @pulumi.getter
493
- def tags(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
494
- """
495
- Name and optionally a tag (format: `name:tag`).
496
-
497
- If exporting to a registry, the name should include the fully qualified
498
- registry address (e.g. `docker.io/pulumi/pulumi:latest`).
499
-
500
- Equivalent to Docker's `--tag` flag.
501
- """
502
- return pulumi.get(self, "tags")
503
-
504
- @tags.setter
505
- def tags(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
506
- pulumi.set(self, "tags", value)
507
-
508
- @property
509
- @pulumi.getter
510
- def targets(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
511
- """
512
- Set the target build stage(s) to build.
513
-
514
- If not specified all targets will be built by default.
515
-
516
- Equivalent to Docker's `--target` flag.
517
- """
518
- return pulumi.get(self, "targets")
519
-
520
- @targets.setter
521
- def targets(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):
522
- pulumi.set(self, "targets", value)
523
-
524
-
525
- class Image(pulumi.CustomResource):
526
- @overload
527
- def __init__(__self__,
528
- resource_name: str,
529
- opts: Optional[pulumi.ResourceOptions] = None,
530
- add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
531
- build_args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
532
- build_on_preview: Optional[pulumi.Input[bool]] = None,
533
- builder: Optional[pulumi.Input[pulumi.InputType['BuilderConfigArgs']]] = None,
534
- cache_from: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['CacheFromEntryArgs']]]]] = None,
535
- cache_to: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['CacheToEntryArgs']]]]] = None,
536
- context: Optional[pulumi.Input[pulumi.InputType['BuildContextArgs']]] = None,
537
- dockerfile: Optional[pulumi.Input[pulumi.InputType['DockerfileArgs']]] = None,
538
- exports: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ExportEntryArgs']]]]] = None,
539
- labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
540
- load: Optional[pulumi.Input[bool]] = None,
541
- network: Optional[pulumi.Input['NetworkMode']] = None,
542
- no_cache: Optional[pulumi.Input[bool]] = None,
543
- platforms: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]] = None,
544
- pull: Optional[pulumi.Input[bool]] = None,
545
- push: Optional[pulumi.Input[bool]] = None,
546
- registries: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RegistryAuthArgs']]]]] = None,
547
- secrets: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
548
- ssh: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['SSHArgs']]]]] = None,
549
- tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
550
- targets: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
551
- __props__=None):
552
- """
553
- A Docker image built using buildx -- Docker's interface to the improved
554
- BuildKit backend.
555
-
556
- ## Stability
557
-
558
- **This resource is experimental and subject to change.**
559
-
560
- API types are unstable. Subsequent releases _may_ require manual edits
561
- to your state file(s) in order to adopt API changes.
562
-
563
- `retainOnDelete: true` is recommended with this resource until it is
564
- stable. This enables future API changes to be adopted more easily by renaming
565
- resources.
566
-
567
- Only use this resource if you understand and accept the risks.
568
-
569
- ## Migrating v3 and v4 Image resources
570
-
571
- The `buildx.Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
572
- Existing `Image` resources can be converted to `build.Image` resources with minor modifications.
573
-
574
- ### Behavioral differences
575
-
576
- There are several key behavioral differences to keep in mind when transitioning images to the new `buildx.Image` resource.
577
-
578
- #### Previews
579
-
580
- Version `3.x` of the Pulumi Docker provider always builds images during preview operations.
581
- This is helpful as a safeguard to prevent "broken" images from merging, but users found the behavior unnecessarily redundant when running previews and updates locally.
582
-
583
- Version `4.x` changed build-on-preview behavior to be opt-in.
584
- By default, `v4.x` `Image` resources do _not_ build during previews, but this behavior can be toggled with the `buildOnPreview` option.
585
- Some users felt this made previews in CI less helpful because they no longer detected bad images by default.
586
-
587
- The default behavior of the `buildx.Image` resource has been changed to strike a better balance between CI use cases and manual updates.
588
- By default, Pulumi will now only build `buildx.Image` resources during previews when it detects a CI environment like GitHub Actions.
589
- Previews run in non-CI environments will not build images.
590
- This behavior is still configurable with `buildOnPreview`.
591
-
592
- #### Push behavior
593
-
594
- Versions `3.x` and `4.x` of the Pulumi Docker provider attempt to push images to remote registries by default.
595
- They expose a `skipPush: true` option to disable pushing.
596
-
597
- The `buildx.Image` resource matches the Docker CLI's behavior and does not push images anywhere by default.
598
-
599
- To push images to a registry you can include `push: true` (equivalent to Docker's `--push` flag) or configure an `export` of type `registry` (equivalent to Docker's `--output type=registry`).
600
- Like Docker, if an image is configured without exports you will see a warning with instructions for how to enable pushing, but the build will still proceed normally.
601
-
602
- #### Secrets
603
-
604
- Version `3.x` of the Pulumi Docker provider supports secrets by way of the `extraOptions` field.
605
-
606
- Version `4.x` of the Pulumi Docker provider does not support secrets.
607
-
608
- The `buildx.Image` resource supports secrets but does not require those secrets to exist on-disk or in environment variables.
609
- Instead, they should be passed directly as values.
610
- (Please be sure to familiarize yourself with Pulumi's [native secret handling](https://www.pulumi.com/docs/concepts/secrets/).)
611
- Pulumi also provides [ESC](https://www.pulumi.com/product/esc/) to make it easier to share secrets across stacks and environments.
612
-
613
- #### Caching
614
-
615
- Version `3.x` of the Pulumi Docker provider exposes `cacheFrom: bool | { stages: [...] }`.
616
- It builds targets individually and pushes them to separate images for caching.
617
-
618
- Version `4.x` exposes a similar parameter `cacheFrom: { images: [...] }` which pushes and pulls inline caches.
619
-
620
- Both versions 3 and 4 require specific environment variables to be set and deviate from Docker's native caching behavior.
621
- This can result in inefficient builds due to unnecessary image pulls, repeated file transfers, etc.
622
-
623
- The `buildx.Image` resource delegates all caching behavior to Docker.
624
- `cacheFrom` and `cacheTo` options (equivalent to Docker's `--cache-to` and `--cache-from`) are exposed and provide additional cache targets, such as local disk, S3 storage, etc.
625
-
626
- #### Outputs
627
-
628
- TODO:
629
-
630
- #### Tag deletion and refreshes
631
-
632
- Versions 3 and 4 of Pulumi Docker provider do not delete tags when the `Image` resource is deleted, nor do they confirm expected tags exist during `refresh` operations.
633
-
634
- The `buidx.Image` will query your registries during `refresh` to ensure the expected tags exist.
635
- If any are missing a subsequent `update` will push them.
636
-
637
- When a `buildx.Image` is deleted, it will _attempt_ to also delete any pushed tags.
638
- Deletion of remote tags is not guaranteed, because not all registries currently support this operation (`docker.io` in particular).
639
-
640
- Use the [`retainOnDelete: true`](https://www.pulumi.com/docs/concepts/options/retainondelete/) option if you do not want tags deleted.
641
-
642
- ### Example migration
643
-
644
- Examples of "fully-featured" `v3` and `v4` `Image` resources are shown below, along with an example `buildx.Image` resource showing how they would look after migration.
645
-
646
- The `v3` resource leverages `buildx` via a `DOCKER_BUILDKIT` environment variable and CLI flags passed in with `extraOption`.
647
- After migration, the environment variable is no longer needed and CLI flags are now properties on the `buildx.Image`.
648
- In almost all cases, properties of `buildx.Image` are named after the Docker CLI flag they correspond to.
649
-
650
- The `v4` resource is less functional than its `v3` counterpart because it lacks the flexibility of `extraOptions`.
651
- It it is shown with parameters similar to the `v3` example for completeness.
652
-
653
- ## Example Usage
654
-
655
- ## Example Usage
656
- ### Push to AWS ECR with caching
657
- ```python
658
- import pulumi
659
- import pulumi_aws as aws
660
- import pulumi_docker as docker
661
-
662
- ecr_repository = aws.ecr.Repository("ecr-repository")
663
- auth_token = aws.ecr.get_authorization_token_output(registry_id=ecr_repository.registry_id)
664
- my_image = docker.buildx.Image("my-image",
665
- cache_from=[docker.buildx.CacheFromEntryArgs(
666
- registry=docker.buildx.CacheFromRegistryArgs(
667
- ref=ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
668
- ),
669
- )],
670
- cache_to=[docker.buildx.CacheToEntryArgs(
671
- registry=docker.buildx.CacheToRegistryArgs(
672
- image_manifest=True,
673
- oci_media_types=True,
674
- ref=ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
675
- ),
676
- )],
677
- context=docker.buildx.BuildContextArgs(
678
- location="./app",
679
- ),
680
- dockerfile=docker.buildx.DockerfileArgs(
681
- location="./Dockerfile",
682
- ),
683
- push=True,
684
- registries=[docker.buildx.RegistryAuthArgs(
685
- address=ecr_repository.repository_url,
686
- password=auth_token.password,
687
- username=auth_token.user_name,
688
- )],
689
- tags=[ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest")])
690
- ```
691
- ### Multi-platform image
692
- ```python
693
- import pulumi
694
- import pulumi_docker as docker
695
-
696
- image = docker.buildx.Image("image",
697
- context=docker.buildx.BuildContextArgs(
698
- location="app",
699
- ),
700
- platforms=[
701
- docker.buildx/image.Platform.PLAN9_AMD64,
702
- docker.buildx/image.Platform.PLAN9_386,
703
- ])
704
- ```
705
- ### Registry export
706
- ```python
707
- import pulumi
708
- import pulumi_docker as docker
709
-
710
- image = docker.buildx.Image("image",
711
- context=docker.buildx.BuildContextArgs(
712
- location="app",
713
- ),
714
- push=True,
715
- registries=[docker.buildx.RegistryAuthArgs(
716
- address="docker.io",
717
- password=docker_hub_password,
718
- username="pulumibot",
719
- )],
720
- tags=["docker.io/pulumi/pulumi:3.107.0"])
721
- ```
722
- ### Caching
723
- ```python
724
- import pulumi
725
- import pulumi_docker as docker
726
-
727
- image = docker.buildx.Image("image",
728
- cache_from=[docker.buildx.CacheFromEntryArgs(
729
- local=docker.buildx.CacheFromLocalArgs(
730
- src="tmp/cache",
731
- ),
732
- )],
733
- cache_to=[docker.buildx.CacheToEntryArgs(
734
- local=docker.buildx.CacheToLocalArgs(
735
- dest="tmp/cache",
736
- mode=docker.buildx/image.CacheMode.MAX,
737
- ),
738
- )],
739
- context=docker.buildx.BuildContextArgs(
740
- location="app",
741
- ))
742
- ```
743
- ### Build arguments
744
- ```python
745
- import pulumi
746
- import pulumi_docker as docker
747
-
748
- image = docker.buildx.Image("image",
749
- build_args={
750
- "SET_ME_TO_TRUE": "true",
751
- },
752
- context=docker.buildx.BuildContextArgs(
753
- location="app",
754
- ))
755
- ```
756
- ### Build targets
757
- ```python
758
- import pulumi
759
- import pulumi_docker as docker
760
-
761
- image = docker.buildx.Image("image",
762
- context=docker.buildx.BuildContextArgs(
763
- location="app",
764
- ),
765
- targets=[
766
- "build-me",
767
- "also-build-me",
768
- ])
769
- ```
770
- ### Named contexts
771
- ```python
772
- import pulumi
773
- import pulumi_docker as docker
774
-
775
- image = docker.buildx.Image("image", context=docker.buildx.BuildContextArgs(
776
- location="app",
777
- named={
778
- "golang:latest": docker.buildx.ContextArgs(
779
- location="docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
780
- ),
781
- },
782
- ))
783
- ```
784
- ### Remote context
785
- ```python
786
- import pulumi
787
- import pulumi_docker as docker
788
-
789
- image = docker.buildx.Image("image", context=docker.buildx.BuildContextArgs(
790
- location="https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
791
- ))
792
- ```
793
- ### Inline Dockerfile
794
- ```python
795
- import pulumi
796
- import pulumi_docker as docker
797
-
798
- image = docker.buildx.Image("image",
799
- context=docker.buildx.BuildContextArgs(
800
- location="app",
801
- ),
802
- dockerfile=docker.buildx.DockerfileArgs(
803
- inline=\"\"\"FROM busybox
804
- COPY hello.c ./
805
- \"\"\",
806
- ))
807
- ```
808
- ### Remote context
809
- ```python
810
- import pulumi
811
- import pulumi_docker as docker
812
-
813
- image = docker.buildx.Image("image",
814
- context=docker.buildx.BuildContextArgs(
815
- location="https://github.com/docker-library/hello-world.git",
816
- ),
817
- dockerfile=docker.buildx.DockerfileArgs(
818
- location="app/Dockerfile",
819
- ))
820
- ```
821
- ### Local export
822
- ```python
823
- import pulumi
824
- import pulumi_docker as docker
825
-
826
- image = docker.buildx.Image("image",
827
- context=docker.buildx.BuildContextArgs(
828
- location="app",
829
- ),
830
- exports=[docker.buildx.ExportEntryArgs(
831
- docker=docker.buildx.ExportDockerArgs(
832
- tar=True,
833
- ),
834
- )])
835
- ```
836
-
837
- :param str resource_name: The name of the resource.
838
- :param pulumi.ResourceOptions opts: Options for the resource.
839
- :param pulumi.Input[Sequence[pulumi.Input[str]]] add_hosts: Custom `host:ip` mappings to use during the build.
840
-
841
- Equivalent to Docker's `--add-host` flag.
842
- :param pulumi.Input[Mapping[str, pulumi.Input[str]]] build_args: `ARG` names and values to set during the build.
843
-
844
- These variables are accessed like environment variables inside `RUN`
845
- instructions.
846
-
847
- Build arguments are persisted in the image, so you should use `secrets`
848
- if these arguments are sensitive.
849
-
850
- Equivalent to Docker's `--build-arg` flag.
851
- :param pulumi.Input[bool] build_on_preview: By default, preview behavior depends on the execution environment. If
852
- Pulumi detects the operation is running on a CI system (GitHub Actions,
853
- Travis CI, Azure Pipelines, etc.) then it will build images during
854
- previews as a safeguard. Otherwise, if not running on CI, previews will
855
- not build images.
856
-
857
- Setting this to `false` forces previews to never perform builds, and
858
- setting it to `true` will always build the image during previews.
859
-
860
- Images built during previews are never exported to registries, however
861
- cache manifests are still exported.
862
-
863
- On-disk Dockerfiles are always validated for syntactic correctness
864
- regardless of this setting.
865
- :param pulumi.Input[pulumi.InputType['BuilderConfigArgs']] builder: Builder configuration.
866
- :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['CacheFromEntryArgs']]]] cache_from: Cache export configuration.
867
-
868
- Equivalent to Docker's `--cache-from` flag.
869
- :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['CacheToEntryArgs']]]] cache_to: Cache import configuration.
870
-
871
- Equivalent to Docker's `--cache-to` flag.
872
- :param pulumi.Input[pulumi.InputType['BuildContextArgs']] context: Build context settings.
873
-
874
- Equivalent to Docker's `PATH | URL | -` positional argument.
875
- :param pulumi.Input[pulumi.InputType['DockerfileArgs']] dockerfile: Dockerfile settings.
876
-
877
- Equivalent to Docker's `--file` flag.
878
- :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ExportEntryArgs']]]] exports: Controls where images are persisted after building.
879
-
880
- Images are only stored in the local cache unless `exports` are
881
- explicitly configured.
882
-
883
- Equivalent to Docker's `--output` flag.
884
- :param pulumi.Input[Mapping[str, pulumi.Input[str]]] labels: Attach arbitrary key/value metadata to the image.
885
-
886
- Equivalent to Docker's `--label` flag.
887
- :param pulumi.Input[bool] load: When `true` the build will automatically include a `docker` export.
888
-
889
- Defaults to `false`.
890
-
891
- Equivalent to Docker's `--load` flag.
892
- :param pulumi.Input['NetworkMode'] network: Set the network mode for `RUN` instructions. Defaults to `default`.
893
-
894
- For custom networks, configure your builder with `--driver-opt network=...`.
895
-
896
- Equivalent to Docker's `--network` flag.
897
- :param pulumi.Input[bool] no_cache: Do not import cache manifests when building the image.
898
-
899
- Equivalent to Docker's `--no-cache` flag.
900
- :param pulumi.Input[Sequence[pulumi.Input['Platform']]] platforms: Set target platform(s) for the build. Defaults to the host's platform.
901
-
902
- Equivalent to Docker's `--platform` flag.
903
- :param pulumi.Input[bool] pull: Always pull referenced images.
904
-
905
- Equivalent to Docker's `--pull` flag.
906
- :param pulumi.Input[bool] push: When `true` the build will automatically include a `registry` export.
907
-
908
- Defaults to `false`.
909
-
910
- Equivalent to Docker's `--push` flag.
911
- :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RegistryAuthArgs']]]] registries: Registry credentials. Required if reading or exporting to private
912
- repositories.
913
-
914
- Credentials are kept in-memory and do not pollute pre-existing
915
- credentials on the host.
916
-
917
- Similar to `docker login`.
918
- :param pulumi.Input[Mapping[str, pulumi.Input[str]]] secrets: A mapping of secret names to their corresponding values.
919
-
920
- Unlike the Docker CLI, these can be passed by value and do not need to
921
- exist on-disk or in environment variables.
922
-
923
- Build arguments and environment variables are persistent in the final
924
- image, so you should use this for sensitive values.
925
-
926
- Similar to Docker's `--secret` flag.
927
- :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['SSHArgs']]]] ssh: SSH agent socket or keys to expose to the build.
928
-
929
- Equivalent to Docker's `--ssh` flag.
930
- :param pulumi.Input[Sequence[pulumi.Input[str]]] tags: Name and optionally a tag (format: `name:tag`).
931
-
932
- If exporting to a registry, the name should include the fully qualified
933
- registry address (e.g. `docker.io/pulumi/pulumi:latest`).
934
-
935
- Equivalent to Docker's `--tag` flag.
936
- :param pulumi.Input[Sequence[pulumi.Input[str]]] targets: Set the target build stage(s) to build.
937
-
938
- If not specified all targets will be built by default.
939
-
940
- Equivalent to Docker's `--target` flag.
941
- """
942
- ...
943
- @overload
944
- def __init__(__self__,
945
- resource_name: str,
946
- args: Optional[ImageArgs] = None,
947
- opts: Optional[pulumi.ResourceOptions] = None):
948
- """
949
- A Docker image built using buildx -- Docker's interface to the improved
950
- BuildKit backend.
951
-
952
- ## Stability
953
-
954
- **This resource is experimental and subject to change.**
955
-
956
- API types are unstable. Subsequent releases _may_ require manual edits
957
- to your state file(s) in order to adopt API changes.
958
-
959
- `retainOnDelete: true` is recommended with this resource until it is
960
- stable. This enables future API changes to be adopted more easily by renaming
961
- resources.
962
-
963
- Only use this resource if you understand and accept the risks.
964
-
965
- ## Migrating v3 and v4 Image resources
966
-
967
- The `buildx.Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
968
- Existing `Image` resources can be converted to `build.Image` resources with minor modifications.
969
-
970
- ### Behavioral differences
971
-
972
- There are several key behavioral differences to keep in mind when transitioning images to the new `buildx.Image` resource.
973
-
974
- #### Previews
975
-
976
- Version `3.x` of the Pulumi Docker provider always builds images during preview operations.
977
- This is helpful as a safeguard to prevent "broken" images from merging, but users found the behavior unnecessarily redundant when running previews and updates locally.
978
-
979
- Version `4.x` changed build-on-preview behavior to be opt-in.
980
- By default, `v4.x` `Image` resources do _not_ build during previews, but this behavior can be toggled with the `buildOnPreview` option.
981
- Some users felt this made previews in CI less helpful because they no longer detected bad images by default.
982
-
983
- The default behavior of the `buildx.Image` resource has been changed to strike a better balance between CI use cases and manual updates.
984
- By default, Pulumi will now only build `buildx.Image` resources during previews when it detects a CI environment like GitHub Actions.
985
- Previews run in non-CI environments will not build images.
986
- This behavior is still configurable with `buildOnPreview`.
987
-
988
- #### Push behavior
989
-
990
- Versions `3.x` and `4.x` of the Pulumi Docker provider attempt to push images to remote registries by default.
991
- They expose a `skipPush: true` option to disable pushing.
992
-
993
- The `buildx.Image` resource matches the Docker CLI's behavior and does not push images anywhere by default.
994
-
995
- To push images to a registry you can include `push: true` (equivalent to Docker's `--push` flag) or configure an `export` of type `registry` (equivalent to Docker's `--output type=registry`).
996
- Like Docker, if an image is configured without exports you will see a warning with instructions for how to enable pushing, but the build will still proceed normally.
997
-
998
- #### Secrets
999
-
1000
- Version `3.x` of the Pulumi Docker provider supports secrets by way of the `extraOptions` field.
1001
-
1002
- Version `4.x` of the Pulumi Docker provider does not support secrets.
1003
-
1004
- The `buildx.Image` resource supports secrets but does not require those secrets to exist on-disk or in environment variables.
1005
- Instead, they should be passed directly as values.
1006
- (Please be sure to familiarize yourself with Pulumi's [native secret handling](https://www.pulumi.com/docs/concepts/secrets/).)
1007
- Pulumi also provides [ESC](https://www.pulumi.com/product/esc/) to make it easier to share secrets across stacks and environments.
1008
-
1009
- #### Caching
1010
-
1011
- Version `3.x` of the Pulumi Docker provider exposes `cacheFrom: bool | { stages: [...] }`.
1012
- It builds targets individually and pushes them to separate images for caching.
1013
-
1014
- Version `4.x` exposes a similar parameter `cacheFrom: { images: [...] }` which pushes and pulls inline caches.
1015
-
1016
- Both versions 3 and 4 require specific environment variables to be set and deviate from Docker's native caching behavior.
1017
- This can result in inefficient builds due to unnecessary image pulls, repeated file transfers, etc.
1018
-
1019
- The `buildx.Image` resource delegates all caching behavior to Docker.
1020
- `cacheFrom` and `cacheTo` options (equivalent to Docker's `--cache-to` and `--cache-from`) are exposed and provide additional cache targets, such as local disk, S3 storage, etc.
1021
-
1022
- #### Outputs
1023
-
1024
- TODO:
1025
-
1026
- #### Tag deletion and refreshes
1027
-
1028
- Versions 3 and 4 of Pulumi Docker provider do not delete tags when the `Image` resource is deleted, nor do they confirm expected tags exist during `refresh` operations.
1029
-
1030
- The `buidx.Image` will query your registries during `refresh` to ensure the expected tags exist.
1031
- If any are missing a subsequent `update` will push them.
1032
-
1033
- When a `buildx.Image` is deleted, it will _attempt_ to also delete any pushed tags.
1034
- Deletion of remote tags is not guaranteed, because not all registries currently support this operation (`docker.io` in particular).
1035
-
1036
- Use the [`retainOnDelete: true`](https://www.pulumi.com/docs/concepts/options/retainondelete/) option if you do not want tags deleted.
1037
-
1038
- ### Example migration
1039
-
1040
- Examples of "fully-featured" `v3` and `v4` `Image` resources are shown below, along with an example `buildx.Image` resource showing how they would look after migration.
1041
-
1042
- The `v3` resource leverages `buildx` via a `DOCKER_BUILDKIT` environment variable and CLI flags passed in with `extraOption`.
1043
- After migration, the environment variable is no longer needed and CLI flags are now properties on the `buildx.Image`.
1044
- In almost all cases, properties of `buildx.Image` are named after the Docker CLI flag they correspond to.
1045
-
1046
- The `v4` resource is less functional than its `v3` counterpart because it lacks the flexibility of `extraOptions`.
1047
- It it is shown with parameters similar to the `v3` example for completeness.
1048
-
1049
- ## Example Usage
1050
-
1051
- ## Example Usage
1052
- ### Push to AWS ECR with caching
1053
- ```python
1054
- import pulumi
1055
- import pulumi_aws as aws
1056
- import pulumi_docker as docker
1057
-
1058
- ecr_repository = aws.ecr.Repository("ecr-repository")
1059
- auth_token = aws.ecr.get_authorization_token_output(registry_id=ecr_repository.registry_id)
1060
- my_image = docker.buildx.Image("my-image",
1061
- cache_from=[docker.buildx.CacheFromEntryArgs(
1062
- registry=docker.buildx.CacheFromRegistryArgs(
1063
- ref=ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
1064
- ),
1065
- )],
1066
- cache_to=[docker.buildx.CacheToEntryArgs(
1067
- registry=docker.buildx.CacheToRegistryArgs(
1068
- image_manifest=True,
1069
- oci_media_types=True,
1070
- ref=ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
1071
- ),
1072
- )],
1073
- context=docker.buildx.BuildContextArgs(
1074
- location="./app",
1075
- ),
1076
- dockerfile=docker.buildx.DockerfileArgs(
1077
- location="./Dockerfile",
1078
- ),
1079
- push=True,
1080
- registries=[docker.buildx.RegistryAuthArgs(
1081
- address=ecr_repository.repository_url,
1082
- password=auth_token.password,
1083
- username=auth_token.user_name,
1084
- )],
1085
- tags=[ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest")])
1086
- ```
1087
- ### Multi-platform image
1088
- ```python
1089
- import pulumi
1090
- import pulumi_docker as docker
1091
-
1092
- image = docker.buildx.Image("image",
1093
- context=docker.buildx.BuildContextArgs(
1094
- location="app",
1095
- ),
1096
- platforms=[
1097
- docker.buildx/image.Platform.PLAN9_AMD64,
1098
- docker.buildx/image.Platform.PLAN9_386,
1099
- ])
1100
- ```
1101
- ### Registry export
1102
- ```python
1103
- import pulumi
1104
- import pulumi_docker as docker
1105
-
1106
- image = docker.buildx.Image("image",
1107
- context=docker.buildx.BuildContextArgs(
1108
- location="app",
1109
- ),
1110
- push=True,
1111
- registries=[docker.buildx.RegistryAuthArgs(
1112
- address="docker.io",
1113
- password=docker_hub_password,
1114
- username="pulumibot",
1115
- )],
1116
- tags=["docker.io/pulumi/pulumi:3.107.0"])
1117
- ```
1118
- ### Caching
1119
- ```python
1120
- import pulumi
1121
- import pulumi_docker as docker
1122
-
1123
- image = docker.buildx.Image("image",
1124
- cache_from=[docker.buildx.CacheFromEntryArgs(
1125
- local=docker.buildx.CacheFromLocalArgs(
1126
- src="tmp/cache",
1127
- ),
1128
- )],
1129
- cache_to=[docker.buildx.CacheToEntryArgs(
1130
- local=docker.buildx.CacheToLocalArgs(
1131
- dest="tmp/cache",
1132
- mode=docker.buildx/image.CacheMode.MAX,
1133
- ),
1134
- )],
1135
- context=docker.buildx.BuildContextArgs(
1136
- location="app",
1137
- ))
1138
- ```
1139
- ### Build arguments
1140
- ```python
1141
- import pulumi
1142
- import pulumi_docker as docker
1143
-
1144
- image = docker.buildx.Image("image",
1145
- build_args={
1146
- "SET_ME_TO_TRUE": "true",
1147
- },
1148
- context=docker.buildx.BuildContextArgs(
1149
- location="app",
1150
- ))
1151
- ```
1152
- ### Build targets
1153
- ```python
1154
- import pulumi
1155
- import pulumi_docker as docker
1156
-
1157
- image = docker.buildx.Image("image",
1158
- context=docker.buildx.BuildContextArgs(
1159
- location="app",
1160
- ),
1161
- targets=[
1162
- "build-me",
1163
- "also-build-me",
1164
- ])
1165
- ```
1166
- ### Named contexts
1167
- ```python
1168
- import pulumi
1169
- import pulumi_docker as docker
1170
-
1171
- image = docker.buildx.Image("image", context=docker.buildx.BuildContextArgs(
1172
- location="app",
1173
- named={
1174
- "golang:latest": docker.buildx.ContextArgs(
1175
- location="docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
1176
- ),
1177
- },
1178
- ))
1179
- ```
1180
- ### Remote context
1181
- ```python
1182
- import pulumi
1183
- import pulumi_docker as docker
1184
-
1185
- image = docker.buildx.Image("image", context=docker.buildx.BuildContextArgs(
1186
- location="https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
1187
- ))
1188
- ```
1189
- ### Inline Dockerfile
1190
- ```python
1191
- import pulumi
1192
- import pulumi_docker as docker
1193
-
1194
- image = docker.buildx.Image("image",
1195
- context=docker.buildx.BuildContextArgs(
1196
- location="app",
1197
- ),
1198
- dockerfile=docker.buildx.DockerfileArgs(
1199
- inline=\"\"\"FROM busybox
1200
- COPY hello.c ./
1201
- \"\"\",
1202
- ))
1203
- ```
1204
- ### Remote context
1205
- ```python
1206
- import pulumi
1207
- import pulumi_docker as docker
1208
-
1209
- image = docker.buildx.Image("image",
1210
- context=docker.buildx.BuildContextArgs(
1211
- location="https://github.com/docker-library/hello-world.git",
1212
- ),
1213
- dockerfile=docker.buildx.DockerfileArgs(
1214
- location="app/Dockerfile",
1215
- ))
1216
- ```
1217
- ### Local export
1218
- ```python
1219
- import pulumi
1220
- import pulumi_docker as docker
1221
-
1222
- image = docker.buildx.Image("image",
1223
- context=docker.buildx.BuildContextArgs(
1224
- location="app",
1225
- ),
1226
- exports=[docker.buildx.ExportEntryArgs(
1227
- docker=docker.buildx.ExportDockerArgs(
1228
- tar=True,
1229
- ),
1230
- )])
1231
- ```
1232
-
1233
- :param str resource_name: The name of the resource.
1234
- :param ImageArgs args: The arguments to use to populate this resource's properties.
1235
- :param pulumi.ResourceOptions opts: Options for the resource.
1236
- """
1237
- ...
1238
- def __init__(__self__, resource_name: str, *args, **kwargs):
1239
- resource_args, opts = _utilities.get_resource_args_opts(ImageArgs, pulumi.ResourceOptions, *args, **kwargs)
1240
- if resource_args is not None:
1241
- __self__._internal_init(resource_name, opts, **resource_args.__dict__)
1242
- else:
1243
- __self__._internal_init(resource_name, *args, **kwargs)
1244
-
1245
- def _internal_init(__self__,
1246
- resource_name: str,
1247
- opts: Optional[pulumi.ResourceOptions] = None,
1248
- add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
1249
- build_args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
1250
- build_on_preview: Optional[pulumi.Input[bool]] = None,
1251
- builder: Optional[pulumi.Input[pulumi.InputType['BuilderConfigArgs']]] = None,
1252
- cache_from: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['CacheFromEntryArgs']]]]] = None,
1253
- cache_to: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['CacheToEntryArgs']]]]] = None,
1254
- context: Optional[pulumi.Input[pulumi.InputType['BuildContextArgs']]] = None,
1255
- dockerfile: Optional[pulumi.Input[pulumi.InputType['DockerfileArgs']]] = None,
1256
- exports: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['ExportEntryArgs']]]]] = None,
1257
- labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
1258
- load: Optional[pulumi.Input[bool]] = None,
1259
- network: Optional[pulumi.Input['NetworkMode']] = None,
1260
- no_cache: Optional[pulumi.Input[bool]] = None,
1261
- platforms: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]] = None,
1262
- pull: Optional[pulumi.Input[bool]] = None,
1263
- push: Optional[pulumi.Input[bool]] = None,
1264
- registries: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RegistryAuthArgs']]]]] = None,
1265
- secrets: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
1266
- ssh: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['SSHArgs']]]]] = None,
1267
- tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
1268
- targets: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
1269
- __props__=None):
1270
- opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
1271
- if not isinstance(opts, pulumi.ResourceOptions):
1272
- raise TypeError('Expected resource options to be a ResourceOptions instance')
1273
- if opts.id is None:
1274
- if __props__ is not None:
1275
- raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
1276
- __props__ = ImageArgs.__new__(ImageArgs)
1277
-
1278
- __props__.__dict__["add_hosts"] = add_hosts
1279
- __props__.__dict__["build_args"] = build_args
1280
- __props__.__dict__["build_on_preview"] = build_on_preview
1281
- __props__.__dict__["builder"] = builder
1282
- __props__.__dict__["cache_from"] = cache_from
1283
- __props__.__dict__["cache_to"] = cache_to
1284
- __props__.__dict__["context"] = context
1285
- __props__.__dict__["dockerfile"] = dockerfile
1286
- __props__.__dict__["exports"] = exports
1287
- __props__.__dict__["labels"] = labels
1288
- __props__.__dict__["load"] = load
1289
- if network is None:
1290
- network = 'default'
1291
- __props__.__dict__["network"] = network
1292
- __props__.__dict__["no_cache"] = no_cache
1293
- __props__.__dict__["platforms"] = platforms
1294
- __props__.__dict__["pull"] = pull
1295
- __props__.__dict__["push"] = push
1296
- __props__.__dict__["registries"] = registries
1297
- __props__.__dict__["secrets"] = secrets
1298
- __props__.__dict__["ssh"] = ssh
1299
- __props__.__dict__["tags"] = tags
1300
- __props__.__dict__["targets"] = targets
1301
- __props__.__dict__["context_hash"] = None
1302
- __props__.__dict__["digests"] = None
1303
- __props__.__dict__["ref"] = None
1304
- super(Image, __self__).__init__(
1305
- 'docker:buildx/image:Image',
1306
- resource_name,
1307
- __props__,
1308
- opts)
1309
-
1310
- @staticmethod
1311
- def get(resource_name: str,
1312
- id: pulumi.Input[str],
1313
- opts: Optional[pulumi.ResourceOptions] = None) -> 'Image':
1314
- """
1315
- Get an existing Image resource's state with the given name, id, and optional extra
1316
- properties used to qualify the lookup.
1317
-
1318
- :param str resource_name: The unique name of the resulting resource.
1319
- :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
1320
- :param pulumi.ResourceOptions opts: Options for the resource.
1321
- """
1322
- opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
1323
-
1324
- __props__ = ImageArgs.__new__(ImageArgs)
1325
-
1326
- __props__.__dict__["add_hosts"] = None
1327
- __props__.__dict__["build_args"] = None
1328
- __props__.__dict__["build_on_preview"] = None
1329
- __props__.__dict__["builder"] = None
1330
- __props__.__dict__["cache_from"] = None
1331
- __props__.__dict__["cache_to"] = None
1332
- __props__.__dict__["context"] = None
1333
- __props__.__dict__["context_hash"] = None
1334
- __props__.__dict__["digests"] = None
1335
- __props__.__dict__["dockerfile"] = None
1336
- __props__.__dict__["exports"] = None
1337
- __props__.__dict__["labels"] = None
1338
- __props__.__dict__["load"] = None
1339
- __props__.__dict__["network"] = None
1340
- __props__.__dict__["no_cache"] = None
1341
- __props__.__dict__["platforms"] = None
1342
- __props__.__dict__["pull"] = None
1343
- __props__.__dict__["push"] = None
1344
- __props__.__dict__["ref"] = None
1345
- __props__.__dict__["registries"] = None
1346
- __props__.__dict__["secrets"] = None
1347
- __props__.__dict__["ssh"] = None
1348
- __props__.__dict__["tags"] = None
1349
- __props__.__dict__["targets"] = None
1350
- return Image(resource_name, opts=opts, __props__=__props__)
1351
-
1352
- @property
1353
- @pulumi.getter(name="addHosts")
1354
- def add_hosts(self) -> pulumi.Output[Optional[Sequence[str]]]:
1355
- """
1356
- Custom `host:ip` mappings to use during the build.
1357
-
1358
- Equivalent to Docker's `--add-host` flag.
1359
- """
1360
- return pulumi.get(self, "add_hosts")
1361
-
1362
- @property
1363
- @pulumi.getter(name="buildArgs")
1364
- def build_args(self) -> pulumi.Output[Optional[Mapping[str, str]]]:
1365
- """
1366
- `ARG` names and values to set during the build.
1367
-
1368
- These variables are accessed like environment variables inside `RUN`
1369
- instructions.
1370
-
1371
- Build arguments are persisted in the image, so you should use `secrets`
1372
- if these arguments are sensitive.
1373
-
1374
- Equivalent to Docker's `--build-arg` flag.
1375
- """
1376
- return pulumi.get(self, "build_args")
1377
-
1378
- @property
1379
- @pulumi.getter(name="buildOnPreview")
1380
- def build_on_preview(self) -> pulumi.Output[Optional[bool]]:
1381
- """
1382
- By default, preview behavior depends on the execution environment. If
1383
- Pulumi detects the operation is running on a CI system (GitHub Actions,
1384
- Travis CI, Azure Pipelines, etc.) then it will build images during
1385
- previews as a safeguard. Otherwise, if not running on CI, previews will
1386
- not build images.
1387
-
1388
- Setting this to `false` forces previews to never perform builds, and
1389
- setting it to `true` will always build the image during previews.
1390
-
1391
- Images built during previews are never exported to registries, however
1392
- cache manifests are still exported.
1393
-
1394
- On-disk Dockerfiles are always validated for syntactic correctness
1395
- regardless of this setting.
1396
- """
1397
- return pulumi.get(self, "build_on_preview")
1398
-
1399
- @property
1400
- @pulumi.getter
1401
- def builder(self) -> pulumi.Output[Optional['outputs.BuilderConfig']]:
1402
- """
1403
- Builder configuration.
1404
- """
1405
- return pulumi.get(self, "builder")
1406
-
1407
- @property
1408
- @pulumi.getter(name="cacheFrom")
1409
- def cache_from(self) -> pulumi.Output[Optional[Sequence['outputs.CacheFromEntry']]]:
1410
- """
1411
- Cache export configuration.
1412
-
1413
- Equivalent to Docker's `--cache-from` flag.
1414
- """
1415
- return pulumi.get(self, "cache_from")
1416
-
1417
- @property
1418
- @pulumi.getter(name="cacheTo")
1419
- def cache_to(self) -> pulumi.Output[Optional[Sequence['outputs.CacheToEntry']]]:
1420
- """
1421
- Cache import configuration.
1422
-
1423
- Equivalent to Docker's `--cache-to` flag.
1424
- """
1425
- return pulumi.get(self, "cache_to")
1426
-
1427
- @property
1428
- @pulumi.getter
1429
- def context(self) -> pulumi.Output[Optional['outputs.BuildContext']]:
1430
- """
1431
- Build context settings.
1432
-
1433
- Equivalent to Docker's `PATH | URL | -` positional argument.
1434
- """
1435
- return pulumi.get(self, "context")
1436
-
1437
- @property
1438
- @pulumi.getter(name="contextHash")
1439
- def context_hash(self) -> pulumi.Output[str]:
1440
- """
1441
- A preliminary hash of the image's build context.
1442
-
1443
- Pulumi uses this to determine if an image _may_ need to be re-built.
1444
- """
1445
- return pulumi.get(self, "context_hash")
1446
-
1447
- @property
1448
- @pulumi.getter
1449
- def digests(self) -> pulumi.Output[Mapping[str, str]]:
1450
- """
1451
- A mapping of target names to the SHA256 digest of their pushed manifest.
1452
-
1453
- If no target was specified 'default' is used as the target name.
1454
-
1455
- Pushed manifests can be referenced as `<tag>@<digest>`.
1456
- """
1457
- return pulumi.get(self, "digests")
1458
-
1459
- @property
1460
- @pulumi.getter
1461
- def dockerfile(self) -> pulumi.Output[Optional['outputs.Dockerfile']]:
1462
- """
1463
- Dockerfile settings.
1464
-
1465
- Equivalent to Docker's `--file` flag.
1466
- """
1467
- return pulumi.get(self, "dockerfile")
1468
-
1469
- @property
1470
- @pulumi.getter
1471
- def exports(self) -> pulumi.Output[Optional[Sequence['outputs.ExportEntry']]]:
1472
- """
1473
- Controls where images are persisted after building.
1474
-
1475
- Images are only stored in the local cache unless `exports` are
1476
- explicitly configured.
1477
-
1478
- Equivalent to Docker's `--output` flag.
1479
- """
1480
- return pulumi.get(self, "exports")
1481
-
1482
- @property
1483
- @pulumi.getter
1484
- def labels(self) -> pulumi.Output[Optional[Mapping[str, str]]]:
1485
- """
1486
- Attach arbitrary key/value metadata to the image.
1487
-
1488
- Equivalent to Docker's `--label` flag.
1489
- """
1490
- return pulumi.get(self, "labels")
1491
-
1492
- @property
1493
- @pulumi.getter
1494
- def load(self) -> pulumi.Output[Optional[bool]]:
1495
- """
1496
- When `true` the build will automatically include a `docker` export.
1497
-
1498
- Defaults to `false`.
1499
-
1500
- Equivalent to Docker's `--load` flag.
1501
- """
1502
- return pulumi.get(self, "load")
1503
-
1504
- @property
1505
- @pulumi.getter
1506
- def network(self) -> pulumi.Output[Optional['NetworkMode']]:
1507
- """
1508
- Set the network mode for `RUN` instructions. Defaults to `default`.
1509
-
1510
- For custom networks, configure your builder with `--driver-opt network=...`.
1511
-
1512
- Equivalent to Docker's `--network` flag.
1513
- """
1514
- return pulumi.get(self, "network")
1515
-
1516
- @property
1517
- @pulumi.getter(name="noCache")
1518
- def no_cache(self) -> pulumi.Output[Optional[bool]]:
1519
- """
1520
- Do not import cache manifests when building the image.
1521
-
1522
- Equivalent to Docker's `--no-cache` flag.
1523
- """
1524
- return pulumi.get(self, "no_cache")
1525
-
1526
- @property
1527
- @pulumi.getter
1528
- def platforms(self) -> pulumi.Output[Optional[Sequence['Platform']]]:
1529
- """
1530
- Set target platform(s) for the build. Defaults to the host's platform.
1531
-
1532
- Equivalent to Docker's `--platform` flag.
1533
- """
1534
- return pulumi.get(self, "platforms")
1535
-
1536
- @property
1537
- @pulumi.getter
1538
- def pull(self) -> pulumi.Output[Optional[bool]]:
1539
- """
1540
- Always pull referenced images.
1541
-
1542
- Equivalent to Docker's `--pull` flag.
1543
- """
1544
- return pulumi.get(self, "pull")
1545
-
1546
- @property
1547
- @pulumi.getter
1548
- def push(self) -> pulumi.Output[Optional[bool]]:
1549
- """
1550
- When `true` the build will automatically include a `registry` export.
1551
-
1552
- Defaults to `false`.
1553
-
1554
- Equivalent to Docker's `--push` flag.
1555
- """
1556
- return pulumi.get(self, "push")
1557
-
1558
- @property
1559
- @pulumi.getter
1560
- def ref(self) -> pulumi.Output[str]:
1561
- """
1562
- If the image was pushed to any registries then this will contain a
1563
- single fully-qualified tag including the build's digest.
1564
-
1565
- This is only for convenience and may not be appropriate for situations
1566
- where multiple tags or registries are involved. In those cases this
1567
- output is not guaranteed to be stable.
1568
-
1569
- For more control over tags consumed by downstream resources you should
1570
- use the `Digests` output.
1571
- """
1572
- return pulumi.get(self, "ref")
1573
-
1574
- @property
1575
- @pulumi.getter
1576
- def registries(self) -> pulumi.Output[Optional[Sequence['outputs.RegistryAuth']]]:
1577
- """
1578
- Registry credentials. Required if reading or exporting to private
1579
- repositories.
1580
-
1581
- Credentials are kept in-memory and do not pollute pre-existing
1582
- credentials on the host.
1583
-
1584
- Similar to `docker login`.
1585
- """
1586
- return pulumi.get(self, "registries")
1587
-
1588
- @property
1589
- @pulumi.getter
1590
- def secrets(self) -> pulumi.Output[Optional[Mapping[str, str]]]:
1591
- """
1592
- A mapping of secret names to their corresponding values.
1593
-
1594
- Unlike the Docker CLI, these can be passed by value and do not need to
1595
- exist on-disk or in environment variables.
1596
-
1597
- Build arguments and environment variables are persistent in the final
1598
- image, so you should use this for sensitive values.
1599
-
1600
- Similar to Docker's `--secret` flag.
1601
- """
1602
- return pulumi.get(self, "secrets")
1603
-
1604
- @property
1605
- @pulumi.getter
1606
- def ssh(self) -> pulumi.Output[Optional[Sequence['outputs.SSH']]]:
1607
- """
1608
- SSH agent socket or keys to expose to the build.
1609
-
1610
- Equivalent to Docker's `--ssh` flag.
1611
- """
1612
- return pulumi.get(self, "ssh")
1613
-
1614
- @property
1615
- @pulumi.getter
1616
- def tags(self) -> pulumi.Output[Optional[Sequence[str]]]:
1617
- """
1618
- Name and optionally a tag (format: `name:tag`).
1619
-
1620
- If exporting to a registry, the name should include the fully qualified
1621
- registry address (e.g. `docker.io/pulumi/pulumi:latest`).
1622
-
1623
- Equivalent to Docker's `--tag` flag.
1624
- """
1625
- return pulumi.get(self, "tags")
1626
-
1627
- @property
1628
- @pulumi.getter
1629
- def targets(self) -> pulumi.Output[Optional[Sequence[str]]]:
1630
- """
1631
- Set the target build stage(s) to build.
1632
-
1633
- If not specified all targets will be built by default.
1634
-
1635
- Equivalent to Docker's `--target` flag.
1636
- """
1637
- return pulumi.get(self, "targets")
1638
-