pulumi-docker-build 0.0.1a3__py3-none-any.whl → 0.0.1a100__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-build might be problematic. Click here for more details.
- pulumi_docker_build/_inputs.py +835 -22
- pulumi_docker_build/_utilities.py +42 -6
- pulumi_docker_build/config/__init__.pyi +5 -0
- pulumi_docker_build/config/vars.py +5 -0
- pulumi_docker_build/image.py +363 -357
- pulumi_docker_build/index.py +98 -69
- pulumi_docker_build/outputs.py +11 -6
- pulumi_docker_build/provider.py +7 -2
- pulumi_docker_build/pulumi-plugin.json +1 -1
- pulumi_docker_build-0.0.1a100.dist-info/METADATA +38 -0
- pulumi_docker_build-0.0.1a100.dist-info/RECORD +17 -0
- {pulumi_docker_build-0.0.1a3.dist-info → pulumi_docker_build-0.0.1a100.dist-info}/WHEEL +1 -1
- pulumi_docker_build-0.0.1a3.dist-info/METADATA +0 -120
- pulumi_docker_build-0.0.1a3.dist-info/RECORD +0 -17
- {pulumi_docker_build-0.0.1a3.dist-info → pulumi_docker_build-0.0.1a100.dist-info}/top_level.txt +0 -0
pulumi_docker_build/image.py
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import copy
|
|
6
6
|
import warnings
|
|
7
|
+
import sys
|
|
7
8
|
import pulumi
|
|
8
9
|
import pulumi.runtime
|
|
9
10
|
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
|
11
|
+
if sys.version_info >= (3, 11):
|
|
12
|
+
from typing import NotRequired, TypedDict, TypeAlias
|
|
13
|
+
else:
|
|
14
|
+
from typing_extensions import NotRequired, TypedDict, TypeAlias
|
|
10
15
|
from . import _utilities
|
|
11
16
|
from . import outputs
|
|
12
17
|
from ._enums import *
|
|
@@ -17,6 +22,7 @@ __all__ = ['ImageArgs', 'Image']
|
|
|
17
22
|
@pulumi.input_type
|
|
18
23
|
class ImageArgs:
|
|
19
24
|
def __init__(__self__, *,
|
|
25
|
+
push: pulumi.Input[bool],
|
|
20
26
|
add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
|
21
27
|
build_args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
22
28
|
build_on_preview: Optional[pulumi.Input[bool]] = None,
|
|
@@ -33,7 +39,6 @@ class ImageArgs:
|
|
|
33
39
|
no_cache: Optional[pulumi.Input[bool]] = None,
|
|
34
40
|
platforms: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]] = None,
|
|
35
41
|
pull: Optional[pulumi.Input[bool]] = None,
|
|
36
|
-
push: Optional[pulumi.Input[bool]] = None,
|
|
37
42
|
registries: Optional[pulumi.Input[Sequence[pulumi.Input['RegistryArgs']]]] = None,
|
|
38
43
|
secrets: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
39
44
|
ssh: Optional[pulumi.Input[Sequence[pulumi.Input['SSHArgs']]]] = None,
|
|
@@ -41,6 +46,11 @@ class ImageArgs:
|
|
|
41
46
|
target: Optional[pulumi.Input[str]] = None):
|
|
42
47
|
"""
|
|
43
48
|
The set of arguments for constructing a Image resource.
|
|
49
|
+
:param pulumi.Input[bool] push: When `true` the build will automatically include a `registry` export.
|
|
50
|
+
|
|
51
|
+
Defaults to `false`.
|
|
52
|
+
|
|
53
|
+
Equivalent to Docker's `--push` flag.
|
|
44
54
|
:param pulumi.Input[Sequence[pulumi.Input[str]]] add_hosts: Custom `host:ip` mappings to use during the build.
|
|
45
55
|
|
|
46
56
|
Equivalent to Docker's `--add-host` flag.
|
|
@@ -53,20 +63,17 @@ class ImageArgs:
|
|
|
53
63
|
if these arguments are sensitive.
|
|
54
64
|
|
|
55
65
|
Equivalent to Docker's `--build-arg` flag.
|
|
56
|
-
:param pulumi.Input[bool] build_on_preview:
|
|
57
|
-
|
|
58
|
-
Travis CI, Azure Pipelines, etc.) then it will build images during
|
|
59
|
-
previews as a safeguard. Otherwise, if not running on CI, previews will
|
|
60
|
-
not build images.
|
|
61
|
-
|
|
62
|
-
Setting this to `false` forces previews to never perform builds, and
|
|
63
|
-
setting it to `true` will always build the image during previews.
|
|
66
|
+
:param pulumi.Input[bool] build_on_preview: Setting this to `false` will always skip image builds during previews,
|
|
67
|
+
and setting it to `true` will always build images during previews.
|
|
64
68
|
|
|
65
69
|
Images built during previews are never exported to registries, however
|
|
66
70
|
cache manifests are still exported.
|
|
67
71
|
|
|
68
72
|
On-disk Dockerfiles are always validated for syntactic correctness
|
|
69
73
|
regardless of this setting.
|
|
74
|
+
|
|
75
|
+
Defaults to `true` as a safeguard against broken images merging as part
|
|
76
|
+
of CI pipelines.
|
|
70
77
|
:param pulumi.Input['BuilderConfigArgs'] builder: Builder configuration.
|
|
71
78
|
:param pulumi.Input[Sequence[pulumi.Input['CacheFromArgs']]] cache_from: Cache export configuration.
|
|
72
79
|
|
|
@@ -74,7 +81,7 @@ class ImageArgs:
|
|
|
74
81
|
:param pulumi.Input[Sequence[pulumi.Input['CacheToArgs']]] cache_to: Cache import configuration.
|
|
75
82
|
|
|
76
83
|
Equivalent to Docker's `--cache-to` flag.
|
|
77
|
-
:param pulumi.Input['BuildContextArgs'] context: Build context settings.
|
|
84
|
+
:param pulumi.Input['BuildContextArgs'] context: Build context settings. Defaults to the current directory.
|
|
78
85
|
|
|
79
86
|
Equivalent to Docker's `PATH | URL | -` positional argument.
|
|
80
87
|
:param pulumi.Input['DockerfileArgs'] dockerfile: Dockerfile settings.
|
|
@@ -131,11 +138,6 @@ class ImageArgs:
|
|
|
131
138
|
:param pulumi.Input[bool] pull: Always pull referenced images.
|
|
132
139
|
|
|
133
140
|
Equivalent to Docker's `--pull` flag.
|
|
134
|
-
:param pulumi.Input[bool] push: When `true` the build will automatically include a `registry` export.
|
|
135
|
-
|
|
136
|
-
Defaults to `false`.
|
|
137
|
-
|
|
138
|
-
Equivalent to Docker's `--push` flag.
|
|
139
141
|
:param pulumi.Input[Sequence[pulumi.Input['RegistryArgs']]] registries: Registry credentials. Required if reading or exporting to private
|
|
140
142
|
repositories.
|
|
141
143
|
|
|
@@ -167,10 +169,13 @@ class ImageArgs:
|
|
|
167
169
|
|
|
168
170
|
Equivalent to Docker's `--target` flag.
|
|
169
171
|
"""
|
|
172
|
+
pulumi.set(__self__, "push", push)
|
|
170
173
|
if add_hosts is not None:
|
|
171
174
|
pulumi.set(__self__, "add_hosts", add_hosts)
|
|
172
175
|
if build_args is not None:
|
|
173
176
|
pulumi.set(__self__, "build_args", build_args)
|
|
177
|
+
if build_on_preview is None:
|
|
178
|
+
build_on_preview = True
|
|
174
179
|
if build_on_preview is not None:
|
|
175
180
|
pulumi.set(__self__, "build_on_preview", build_on_preview)
|
|
176
181
|
if builder is not None:
|
|
@@ -201,8 +206,6 @@ class ImageArgs:
|
|
|
201
206
|
pulumi.set(__self__, "platforms", platforms)
|
|
202
207
|
if pull is not None:
|
|
203
208
|
pulumi.set(__self__, "pull", pull)
|
|
204
|
-
if push is not None:
|
|
205
|
-
pulumi.set(__self__, "push", push)
|
|
206
209
|
if registries is not None:
|
|
207
210
|
pulumi.set(__self__, "registries", registries)
|
|
208
211
|
if secrets is not None:
|
|
@@ -214,6 +217,22 @@ class ImageArgs:
|
|
|
214
217
|
if target is not None:
|
|
215
218
|
pulumi.set(__self__, "target", target)
|
|
216
219
|
|
|
220
|
+
@property
|
|
221
|
+
@pulumi.getter
|
|
222
|
+
def push(self) -> pulumi.Input[bool]:
|
|
223
|
+
"""
|
|
224
|
+
When `true` the build will automatically include a `registry` export.
|
|
225
|
+
|
|
226
|
+
Defaults to `false`.
|
|
227
|
+
|
|
228
|
+
Equivalent to Docker's `--push` flag.
|
|
229
|
+
"""
|
|
230
|
+
return pulumi.get(self, "push")
|
|
231
|
+
|
|
232
|
+
@push.setter
|
|
233
|
+
def push(self, value: pulumi.Input[bool]):
|
|
234
|
+
pulumi.set(self, "push", value)
|
|
235
|
+
|
|
217
236
|
@property
|
|
218
237
|
@pulumi.getter(name="addHosts")
|
|
219
238
|
def add_hosts(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
|
|
@@ -252,20 +271,17 @@ class ImageArgs:
|
|
|
252
271
|
@pulumi.getter(name="buildOnPreview")
|
|
253
272
|
def build_on_preview(self) -> Optional[pulumi.Input[bool]]:
|
|
254
273
|
"""
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
Travis CI, Azure Pipelines, etc.) then it will build images during
|
|
258
|
-
previews as a safeguard. Otherwise, if not running on CI, previews will
|
|
259
|
-
not build images.
|
|
260
|
-
|
|
261
|
-
Setting this to `false` forces previews to never perform builds, and
|
|
262
|
-
setting it to `true` will always build the image during previews.
|
|
274
|
+
Setting this to `false` will always skip image builds during previews,
|
|
275
|
+
and setting it to `true` will always build images during previews.
|
|
263
276
|
|
|
264
277
|
Images built during previews are never exported to registries, however
|
|
265
278
|
cache manifests are still exported.
|
|
266
279
|
|
|
267
280
|
On-disk Dockerfiles are always validated for syntactic correctness
|
|
268
281
|
regardless of this setting.
|
|
282
|
+
|
|
283
|
+
Defaults to `true` as a safeguard against broken images merging as part
|
|
284
|
+
of CI pipelines.
|
|
269
285
|
"""
|
|
270
286
|
return pulumi.get(self, "build_on_preview")
|
|
271
287
|
|
|
@@ -317,7 +333,7 @@ class ImageArgs:
|
|
|
317
333
|
@pulumi.getter
|
|
318
334
|
def context(self) -> Optional[pulumi.Input['BuildContextArgs']]:
|
|
319
335
|
"""
|
|
320
|
-
Build context settings.
|
|
336
|
+
Build context settings. Defaults to the current directory.
|
|
321
337
|
|
|
322
338
|
Equivalent to Docker's `PATH | URL | -` positional argument.
|
|
323
339
|
"""
|
|
@@ -480,22 +496,6 @@ class ImageArgs:
|
|
|
480
496
|
def pull(self, value: Optional[pulumi.Input[bool]]):
|
|
481
497
|
pulumi.set(self, "pull", value)
|
|
482
498
|
|
|
483
|
-
@property
|
|
484
|
-
@pulumi.getter
|
|
485
|
-
def push(self) -> Optional[pulumi.Input[bool]]:
|
|
486
|
-
"""
|
|
487
|
-
When `true` the build will automatically include a `registry` export.
|
|
488
|
-
|
|
489
|
-
Defaults to `false`.
|
|
490
|
-
|
|
491
|
-
Equivalent to Docker's `--push` flag.
|
|
492
|
-
"""
|
|
493
|
-
return pulumi.get(self, "push")
|
|
494
|
-
|
|
495
|
-
@push.setter
|
|
496
|
-
def push(self, value: Optional[pulumi.Input[bool]]):
|
|
497
|
-
pulumi.set(self, "push", value)
|
|
498
|
-
|
|
499
499
|
@property
|
|
500
500
|
@pulumi.getter
|
|
501
501
|
def registries(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['RegistryArgs']]]]:
|
|
@@ -590,13 +590,13 @@ class Image(pulumi.CustomResource):
|
|
|
590
590
|
add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
|
591
591
|
build_args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
592
592
|
build_on_preview: Optional[pulumi.Input[bool]] = None,
|
|
593
|
-
builder: Optional[pulumi.Input[
|
|
594
|
-
cache_from: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
595
|
-
cache_to: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
596
|
-
context: Optional[pulumi.Input[
|
|
597
|
-
dockerfile: Optional[pulumi.Input[
|
|
593
|
+
builder: Optional[pulumi.Input[Union['BuilderConfigArgs', 'BuilderConfigArgsDict']]] = None,
|
|
594
|
+
cache_from: Optional[pulumi.Input[Sequence[pulumi.Input[Union['CacheFromArgs', 'CacheFromArgsDict']]]]] = None,
|
|
595
|
+
cache_to: Optional[pulumi.Input[Sequence[pulumi.Input[Union['CacheToArgs', 'CacheToArgsDict']]]]] = None,
|
|
596
|
+
context: Optional[pulumi.Input[Union['BuildContextArgs', 'BuildContextArgsDict']]] = None,
|
|
597
|
+
dockerfile: Optional[pulumi.Input[Union['DockerfileArgs', 'DockerfileArgsDict']]] = None,
|
|
598
598
|
exec_: Optional[pulumi.Input[bool]] = None,
|
|
599
|
-
exports: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
599
|
+
exports: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ExportArgs', 'ExportArgsDict']]]]] = None,
|
|
600
600
|
labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
601
601
|
load: Optional[pulumi.Input[bool]] = None,
|
|
602
602
|
network: Optional[pulumi.Input['NetworkMode']] = None,
|
|
@@ -604,9 +604,9 @@ class Image(pulumi.CustomResource):
|
|
|
604
604
|
platforms: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]] = None,
|
|
605
605
|
pull: Optional[pulumi.Input[bool]] = None,
|
|
606
606
|
push: Optional[pulumi.Input[bool]] = None,
|
|
607
|
-
registries: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
607
|
+
registries: Optional[pulumi.Input[Sequence[pulumi.Input[Union['RegistryArgs', 'RegistryArgsDict']]]]] = None,
|
|
608
608
|
secrets: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
609
|
-
ssh: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
609
|
+
ssh: Optional[pulumi.Input[Sequence[pulumi.Input[Union['SSHArgs', 'SSHArgsDict']]]]] = None,
|
|
610
610
|
tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
|
611
611
|
target: Optional[pulumi.Input[str]] = None,
|
|
612
612
|
__props__=None):
|
|
@@ -616,20 +616,14 @@ class Image(pulumi.CustomResource):
|
|
|
616
616
|
|
|
617
617
|
## Stability
|
|
618
618
|
|
|
619
|
-
**This resource is
|
|
620
|
-
|
|
621
|
-
API types are unstable. Subsequent releases _may_ require manual edits
|
|
622
|
-
to your state file(s) in order to adopt API changes.
|
|
619
|
+
**This resource is pre-1.0 and in public preview.**
|
|
623
620
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
resources.
|
|
621
|
+
We will strive to keep APIs and behavior as stable as possible, but we
|
|
622
|
+
cannot guarantee stability until version 1.0.
|
|
627
623
|
|
|
628
|
-
|
|
624
|
+
## Migrating Pulumi Docker v3 and v4 Image resources
|
|
629
625
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
The `Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
|
|
626
|
+
This provider's `Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
|
|
633
627
|
Existing `Image` resources can be converted to the docker-build `Image` resources with minor modifications.
|
|
634
628
|
|
|
635
629
|
### Behavioral differences
|
|
@@ -643,19 +637,17 @@ class Image(pulumi.CustomResource):
|
|
|
643
637
|
|
|
644
638
|
Version `4.x` changed build-on-preview behavior to be opt-in.
|
|
645
639
|
By default, `v4.x` `Image` resources do _not_ build during previews, but this behavior can be toggled with the `buildOnPreview` option.
|
|
646
|
-
|
|
640
|
+
Several users reported outages due to the default behavior allowing bad images to accidentally sneak through CI.
|
|
647
641
|
|
|
648
|
-
The default behavior of
|
|
649
|
-
|
|
650
|
-
Previews run in non-CI environments will not build images.
|
|
651
|
-
This behavior is still configurable with `buildOnPreview`.
|
|
642
|
+
The default behavior of this provider's `Image` resource is similar to `3.x` and will build images during previews.
|
|
643
|
+
This behavior can be changed by specifying `buildOnPreview`.
|
|
652
644
|
|
|
653
645
|
#### Push behavior
|
|
654
646
|
|
|
655
647
|
Versions `3.x` and `4.x` of the Pulumi Docker provider attempt to push images to remote registries by default.
|
|
656
648
|
They expose a `skipPush: true` option to disable pushing.
|
|
657
649
|
|
|
658
|
-
|
|
650
|
+
This provider's `Image` resource matches the Docker CLI's behavior and does not push images anywhere by default.
|
|
659
651
|
|
|
660
652
|
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`).
|
|
661
653
|
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.
|
|
@@ -726,191 +718,203 @@ class Image(pulumi.CustomResource):
|
|
|
726
718
|
```python
|
|
727
719
|
import pulumi
|
|
728
720
|
import pulumi_aws as aws
|
|
729
|
-
import
|
|
721
|
+
import pulumi_docker_build as docker_build
|
|
730
722
|
|
|
731
723
|
ecr_repository = aws.ecr.Repository("ecr-repository")
|
|
732
724
|
auth_token = aws.ecr.get_authorization_token_output(registry_id=ecr_repository.registry_id)
|
|
733
|
-
my_image =
|
|
734
|
-
cache_from=[
|
|
735
|
-
registry
|
|
736
|
-
ref
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
cache_to=[
|
|
740
|
-
registry
|
|
741
|
-
image_manifest
|
|
742
|
-
oci_media_types
|
|
743
|
-
ref
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
context=
|
|
747
|
-
location
|
|
748
|
-
|
|
725
|
+
my_image = docker_build.Image("my-image",
|
|
726
|
+
cache_from=[{
|
|
727
|
+
"registry": {
|
|
728
|
+
"ref": ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
|
|
729
|
+
},
|
|
730
|
+
}],
|
|
731
|
+
cache_to=[{
|
|
732
|
+
"registry": {
|
|
733
|
+
"image_manifest": True,
|
|
734
|
+
"oci_media_types": True,
|
|
735
|
+
"ref": ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
|
|
736
|
+
},
|
|
737
|
+
}],
|
|
738
|
+
context={
|
|
739
|
+
"location": "./app",
|
|
740
|
+
},
|
|
749
741
|
push=True,
|
|
750
|
-
registries=[
|
|
751
|
-
address
|
|
752
|
-
password
|
|
753
|
-
username
|
|
754
|
-
|
|
742
|
+
registries=[{
|
|
743
|
+
"address": ecr_repository.repository_url,
|
|
744
|
+
"password": auth_token.password,
|
|
745
|
+
"username": auth_token.user_name,
|
|
746
|
+
}],
|
|
755
747
|
tags=[ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest")])
|
|
756
748
|
pulumi.export("ref", my_image.ref)
|
|
757
749
|
```
|
|
758
750
|
### Multi-platform image
|
|
759
751
|
```python
|
|
760
752
|
import pulumi
|
|
761
|
-
import
|
|
753
|
+
import pulumi_docker_build as docker_build
|
|
762
754
|
|
|
763
|
-
image =
|
|
764
|
-
context=
|
|
765
|
-
location
|
|
766
|
-
|
|
755
|
+
image = docker_build.Image("image",
|
|
756
|
+
context={
|
|
757
|
+
"location": "app",
|
|
758
|
+
},
|
|
767
759
|
platforms=[
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
]
|
|
760
|
+
docker_build.Platform.PLAN9_AMD64,
|
|
761
|
+
docker_build.Platform.PLAN9_386,
|
|
762
|
+
],
|
|
763
|
+
push=False)
|
|
771
764
|
```
|
|
772
765
|
### Registry export
|
|
773
766
|
```python
|
|
774
767
|
import pulumi
|
|
775
|
-
import
|
|
768
|
+
import pulumi_docker_build as docker_build
|
|
776
769
|
|
|
777
|
-
image =
|
|
778
|
-
context=
|
|
779
|
-
location
|
|
780
|
-
|
|
770
|
+
image = docker_build.Image("image",
|
|
771
|
+
context={
|
|
772
|
+
"location": "app",
|
|
773
|
+
},
|
|
781
774
|
push=True,
|
|
782
|
-
registries=[
|
|
783
|
-
address
|
|
784
|
-
password
|
|
785
|
-
username
|
|
786
|
-
|
|
775
|
+
registries=[{
|
|
776
|
+
"address": "docker.io",
|
|
777
|
+
"password": docker_hub_password,
|
|
778
|
+
"username": "pulumibot",
|
|
779
|
+
}],
|
|
787
780
|
tags=["docker.io/pulumi/pulumi:3.107.0"])
|
|
788
781
|
pulumi.export("ref", my_image["ref"])
|
|
789
782
|
```
|
|
790
783
|
### Caching
|
|
791
784
|
```python
|
|
792
785
|
import pulumi
|
|
793
|
-
import
|
|
794
|
-
|
|
795
|
-
image =
|
|
796
|
-
cache_from=[
|
|
797
|
-
local
|
|
798
|
-
src
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
cache_to=[
|
|
802
|
-
local
|
|
803
|
-
dest
|
|
804
|
-
mode
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
context=
|
|
808
|
-
location
|
|
809
|
-
|
|
786
|
+
import pulumi_docker_build as docker_build
|
|
787
|
+
|
|
788
|
+
image = docker_build.Image("image",
|
|
789
|
+
cache_from=[{
|
|
790
|
+
"local": {
|
|
791
|
+
"src": "tmp/cache",
|
|
792
|
+
},
|
|
793
|
+
}],
|
|
794
|
+
cache_to=[{
|
|
795
|
+
"local": {
|
|
796
|
+
"dest": "tmp/cache",
|
|
797
|
+
"mode": docker_build.CacheMode.MAX,
|
|
798
|
+
},
|
|
799
|
+
}],
|
|
800
|
+
context={
|
|
801
|
+
"location": "app",
|
|
802
|
+
},
|
|
803
|
+
push=False)
|
|
810
804
|
```
|
|
811
805
|
### Docker Build Cloud
|
|
812
806
|
```python
|
|
813
807
|
import pulumi
|
|
814
|
-
import
|
|
815
|
-
|
|
816
|
-
image =
|
|
817
|
-
builder=
|
|
818
|
-
name
|
|
819
|
-
|
|
820
|
-
context=
|
|
821
|
-
location
|
|
822
|
-
|
|
823
|
-
exec_=True
|
|
808
|
+
import pulumi_docker_build as docker_build
|
|
809
|
+
|
|
810
|
+
image = docker_build.Image("image",
|
|
811
|
+
builder={
|
|
812
|
+
"name": "cloud-builder-name",
|
|
813
|
+
},
|
|
814
|
+
context={
|
|
815
|
+
"location": "app",
|
|
816
|
+
},
|
|
817
|
+
exec_=True,
|
|
818
|
+
push=False)
|
|
824
819
|
```
|
|
825
820
|
### Build arguments
|
|
826
821
|
```python
|
|
827
822
|
import pulumi
|
|
828
|
-
import
|
|
823
|
+
import pulumi_docker_build as docker_build
|
|
829
824
|
|
|
830
|
-
image =
|
|
825
|
+
image = docker_build.Image("image",
|
|
831
826
|
build_args={
|
|
832
827
|
"SET_ME_TO_TRUE": "true",
|
|
833
828
|
},
|
|
834
|
-
context=
|
|
835
|
-
location
|
|
836
|
-
|
|
829
|
+
context={
|
|
830
|
+
"location": "app",
|
|
831
|
+
},
|
|
832
|
+
push=False)
|
|
837
833
|
```
|
|
838
834
|
### Build target
|
|
839
835
|
```python
|
|
840
836
|
import pulumi
|
|
841
|
-
import
|
|
837
|
+
import pulumi_docker_build as docker_build
|
|
842
838
|
|
|
843
|
-
image =
|
|
844
|
-
context=
|
|
845
|
-
location
|
|
846
|
-
|
|
839
|
+
image = docker_build.Image("image",
|
|
840
|
+
context={
|
|
841
|
+
"location": "app",
|
|
842
|
+
},
|
|
843
|
+
push=False,
|
|
847
844
|
target="build-me")
|
|
848
845
|
```
|
|
849
846
|
### Named contexts
|
|
850
847
|
```python
|
|
851
848
|
import pulumi
|
|
852
|
-
import
|
|
853
|
-
|
|
854
|
-
image =
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
"
|
|
858
|
-
|
|
859
|
-
|
|
849
|
+
import pulumi_docker_build as docker_build
|
|
850
|
+
|
|
851
|
+
image = docker_build.Image("image",
|
|
852
|
+
context={
|
|
853
|
+
"location": "app",
|
|
854
|
+
"named": {
|
|
855
|
+
"golang:latest": {
|
|
856
|
+
"location": "docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
|
|
857
|
+
},
|
|
858
|
+
},
|
|
860
859
|
},
|
|
861
|
-
|
|
860
|
+
push=False)
|
|
862
861
|
```
|
|
863
862
|
### Remote context
|
|
864
863
|
```python
|
|
865
864
|
import pulumi
|
|
866
|
-
import
|
|
865
|
+
import pulumi_docker_build as docker_build
|
|
867
866
|
|
|
868
|
-
image =
|
|
869
|
-
|
|
870
|
-
|
|
867
|
+
image = docker_build.Image("image",
|
|
868
|
+
context={
|
|
869
|
+
"location": "https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
|
|
870
|
+
},
|
|
871
|
+
push=False)
|
|
871
872
|
```
|
|
872
873
|
### Inline Dockerfile
|
|
873
874
|
```python
|
|
874
875
|
import pulumi
|
|
875
|
-
import
|
|
876
|
-
|
|
877
|
-
image =
|
|
878
|
-
context=
|
|
879
|
-
location
|
|
880
|
-
|
|
881
|
-
dockerfile=
|
|
882
|
-
inline
|
|
876
|
+
import pulumi_docker_build as docker_build
|
|
877
|
+
|
|
878
|
+
image = docker_build.Image("image",
|
|
879
|
+
context={
|
|
880
|
+
"location": "app",
|
|
881
|
+
},
|
|
882
|
+
dockerfile={
|
|
883
|
+
"inline": \"\"\"FROM busybox
|
|
883
884
|
COPY hello.c ./
|
|
884
885
|
\"\"\",
|
|
885
|
-
|
|
886
|
+
},
|
|
887
|
+
push=False)
|
|
886
888
|
```
|
|
887
889
|
### Remote context
|
|
888
890
|
```python
|
|
889
891
|
import pulumi
|
|
890
|
-
import
|
|
891
|
-
|
|
892
|
-
image =
|
|
893
|
-
context=
|
|
894
|
-
location
|
|
895
|
-
|
|
896
|
-
dockerfile=
|
|
897
|
-
location
|
|
898
|
-
|
|
892
|
+
import pulumi_docker_build as docker_build
|
|
893
|
+
|
|
894
|
+
image = docker_build.Image("image",
|
|
895
|
+
context={
|
|
896
|
+
"location": "https://github.com/docker-library/hello-world.git",
|
|
897
|
+
},
|
|
898
|
+
dockerfile={
|
|
899
|
+
"location": "app/Dockerfile",
|
|
900
|
+
},
|
|
901
|
+
push=False)
|
|
899
902
|
```
|
|
900
903
|
### Local export
|
|
901
904
|
```python
|
|
902
905
|
import pulumi
|
|
903
|
-
import
|
|
904
|
-
|
|
905
|
-
image =
|
|
906
|
-
context=
|
|
907
|
-
location
|
|
908
|
-
|
|
909
|
-
exports=[
|
|
910
|
-
docker
|
|
911
|
-
tar
|
|
912
|
-
|
|
913
|
-
|
|
906
|
+
import pulumi_docker_build as docker_build
|
|
907
|
+
|
|
908
|
+
image = docker_build.Image("image",
|
|
909
|
+
context={
|
|
910
|
+
"location": "app",
|
|
911
|
+
},
|
|
912
|
+
exports=[{
|
|
913
|
+
"docker": {
|
|
914
|
+
"tar": True,
|
|
915
|
+
},
|
|
916
|
+
}],
|
|
917
|
+
push=False)
|
|
914
918
|
```
|
|
915
919
|
|
|
916
920
|
:param str resource_name: The name of the resource.
|
|
@@ -927,31 +931,28 @@ class Image(pulumi.CustomResource):
|
|
|
927
931
|
if these arguments are sensitive.
|
|
928
932
|
|
|
929
933
|
Equivalent to Docker's `--build-arg` flag.
|
|
930
|
-
:param pulumi.Input[bool] build_on_preview:
|
|
931
|
-
|
|
932
|
-
Travis CI, Azure Pipelines, etc.) then it will build images during
|
|
933
|
-
previews as a safeguard. Otherwise, if not running on CI, previews will
|
|
934
|
-
not build images.
|
|
935
|
-
|
|
936
|
-
Setting this to `false` forces previews to never perform builds, and
|
|
937
|
-
setting it to `true` will always build the image during previews.
|
|
934
|
+
:param pulumi.Input[bool] build_on_preview: Setting this to `false` will always skip image builds during previews,
|
|
935
|
+
and setting it to `true` will always build images during previews.
|
|
938
936
|
|
|
939
937
|
Images built during previews are never exported to registries, however
|
|
940
938
|
cache manifests are still exported.
|
|
941
939
|
|
|
942
940
|
On-disk Dockerfiles are always validated for syntactic correctness
|
|
943
941
|
regardless of this setting.
|
|
944
|
-
|
|
945
|
-
|
|
942
|
+
|
|
943
|
+
Defaults to `true` as a safeguard against broken images merging as part
|
|
944
|
+
of CI pipelines.
|
|
945
|
+
:param pulumi.Input[Union['BuilderConfigArgs', 'BuilderConfigArgsDict']] builder: Builder configuration.
|
|
946
|
+
:param pulumi.Input[Sequence[pulumi.Input[Union['CacheFromArgs', 'CacheFromArgsDict']]]] cache_from: Cache export configuration.
|
|
946
947
|
|
|
947
948
|
Equivalent to Docker's `--cache-from` flag.
|
|
948
|
-
:param pulumi.Input[Sequence[pulumi.Input[
|
|
949
|
+
:param pulumi.Input[Sequence[pulumi.Input[Union['CacheToArgs', 'CacheToArgsDict']]]] cache_to: Cache import configuration.
|
|
949
950
|
|
|
950
951
|
Equivalent to Docker's `--cache-to` flag.
|
|
951
|
-
:param pulumi.Input[
|
|
952
|
+
:param pulumi.Input[Union['BuildContextArgs', 'BuildContextArgsDict']] context: Build context settings. Defaults to the current directory.
|
|
952
953
|
|
|
953
954
|
Equivalent to Docker's `PATH | URL | -` positional argument.
|
|
954
|
-
:param pulumi.Input[
|
|
955
|
+
:param pulumi.Input[Union['DockerfileArgs', 'DockerfileArgsDict']] dockerfile: Dockerfile settings.
|
|
955
956
|
|
|
956
957
|
Equivalent to Docker's `--file` flag.
|
|
957
958
|
:param pulumi.Input[bool] exec_: Use `exec` mode to build this image.
|
|
@@ -974,7 +975,7 @@ class Image(pulumi.CustomResource):
|
|
|
974
975
|
to surface fine-grained errors and warnings. Additionally credentials
|
|
975
976
|
are temporarily written to disk in order to provide them to the
|
|
976
977
|
`docker-buildx` binary.
|
|
977
|
-
:param pulumi.Input[Sequence[pulumi.Input[
|
|
978
|
+
:param pulumi.Input[Sequence[pulumi.Input[Union['ExportArgs', 'ExportArgsDict']]]] exports: Controls where images are persisted after building.
|
|
978
979
|
|
|
979
980
|
Images are only stored in the local cache unless `exports` are
|
|
980
981
|
explicitly configured.
|
|
@@ -1010,7 +1011,7 @@ class Image(pulumi.CustomResource):
|
|
|
1010
1011
|
Defaults to `false`.
|
|
1011
1012
|
|
|
1012
1013
|
Equivalent to Docker's `--push` flag.
|
|
1013
|
-
:param pulumi.Input[Sequence[pulumi.Input[
|
|
1014
|
+
:param pulumi.Input[Sequence[pulumi.Input[Union['RegistryArgs', 'RegistryArgsDict']]]] registries: Registry credentials. Required if reading or exporting to private
|
|
1014
1015
|
repositories.
|
|
1015
1016
|
|
|
1016
1017
|
Credentials are kept in-memory and do not pollute pre-existing
|
|
@@ -1026,7 +1027,7 @@ class Image(pulumi.CustomResource):
|
|
|
1026
1027
|
image, so you should use this for sensitive values.
|
|
1027
1028
|
|
|
1028
1029
|
Similar to Docker's `--secret` flag.
|
|
1029
|
-
:param pulumi.Input[Sequence[pulumi.Input[
|
|
1030
|
+
:param pulumi.Input[Sequence[pulumi.Input[Union['SSHArgs', 'SSHArgsDict']]]] ssh: SSH agent socket or keys to expose to the build.
|
|
1030
1031
|
|
|
1031
1032
|
Equivalent to Docker's `--ssh` flag.
|
|
1032
1033
|
:param pulumi.Input[Sequence[pulumi.Input[str]]] tags: Name and optionally a tag (format: `name:tag`).
|
|
@@ -1045,7 +1046,7 @@ class Image(pulumi.CustomResource):
|
|
|
1045
1046
|
@overload
|
|
1046
1047
|
def __init__(__self__,
|
|
1047
1048
|
resource_name: str,
|
|
1048
|
-
args:
|
|
1049
|
+
args: ImageArgs,
|
|
1049
1050
|
opts: Optional[pulumi.ResourceOptions] = None):
|
|
1050
1051
|
"""
|
|
1051
1052
|
A Docker image built using buildx -- Docker's interface to the improved
|
|
@@ -1053,20 +1054,14 @@ class Image(pulumi.CustomResource):
|
|
|
1053
1054
|
|
|
1054
1055
|
## Stability
|
|
1055
1056
|
|
|
1056
|
-
**This resource is
|
|
1057
|
-
|
|
1058
|
-
API types are unstable. Subsequent releases _may_ require manual edits
|
|
1059
|
-
to your state file(s) in order to adopt API changes.
|
|
1057
|
+
**This resource is pre-1.0 and in public preview.**
|
|
1060
1058
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
resources.
|
|
1059
|
+
We will strive to keep APIs and behavior as stable as possible, but we
|
|
1060
|
+
cannot guarantee stability until version 1.0.
|
|
1064
1061
|
|
|
1065
|
-
|
|
1062
|
+
## Migrating Pulumi Docker v3 and v4 Image resources
|
|
1066
1063
|
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
The `Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
|
|
1064
|
+
This provider's `Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
|
|
1070
1065
|
Existing `Image` resources can be converted to the docker-build `Image` resources with minor modifications.
|
|
1071
1066
|
|
|
1072
1067
|
### Behavioral differences
|
|
@@ -1080,19 +1075,17 @@ class Image(pulumi.CustomResource):
|
|
|
1080
1075
|
|
|
1081
1076
|
Version `4.x` changed build-on-preview behavior to be opt-in.
|
|
1082
1077
|
By default, `v4.x` `Image` resources do _not_ build during previews, but this behavior can be toggled with the `buildOnPreview` option.
|
|
1083
|
-
|
|
1078
|
+
Several users reported outages due to the default behavior allowing bad images to accidentally sneak through CI.
|
|
1084
1079
|
|
|
1085
|
-
The default behavior of
|
|
1086
|
-
|
|
1087
|
-
Previews run in non-CI environments will not build images.
|
|
1088
|
-
This behavior is still configurable with `buildOnPreview`.
|
|
1080
|
+
The default behavior of this provider's `Image` resource is similar to `3.x` and will build images during previews.
|
|
1081
|
+
This behavior can be changed by specifying `buildOnPreview`.
|
|
1089
1082
|
|
|
1090
1083
|
#### Push behavior
|
|
1091
1084
|
|
|
1092
1085
|
Versions `3.x` and `4.x` of the Pulumi Docker provider attempt to push images to remote registries by default.
|
|
1093
1086
|
They expose a `skipPush: true` option to disable pushing.
|
|
1094
1087
|
|
|
1095
|
-
|
|
1088
|
+
This provider's `Image` resource matches the Docker CLI's behavior and does not push images anywhere by default.
|
|
1096
1089
|
|
|
1097
1090
|
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`).
|
|
1098
1091
|
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.
|
|
@@ -1163,191 +1156,203 @@ class Image(pulumi.CustomResource):
|
|
|
1163
1156
|
```python
|
|
1164
1157
|
import pulumi
|
|
1165
1158
|
import pulumi_aws as aws
|
|
1166
|
-
import
|
|
1159
|
+
import pulumi_docker_build as docker_build
|
|
1167
1160
|
|
|
1168
1161
|
ecr_repository = aws.ecr.Repository("ecr-repository")
|
|
1169
1162
|
auth_token = aws.ecr.get_authorization_token_output(registry_id=ecr_repository.registry_id)
|
|
1170
|
-
my_image =
|
|
1171
|
-
cache_from=[
|
|
1172
|
-
registry
|
|
1173
|
-
ref
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
cache_to=[
|
|
1177
|
-
registry
|
|
1178
|
-
image_manifest
|
|
1179
|
-
oci_media_types
|
|
1180
|
-
ref
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
context=
|
|
1184
|
-
location
|
|
1185
|
-
|
|
1163
|
+
my_image = docker_build.Image("my-image",
|
|
1164
|
+
cache_from=[{
|
|
1165
|
+
"registry": {
|
|
1166
|
+
"ref": ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
|
|
1167
|
+
},
|
|
1168
|
+
}],
|
|
1169
|
+
cache_to=[{
|
|
1170
|
+
"registry": {
|
|
1171
|
+
"image_manifest": True,
|
|
1172
|
+
"oci_media_types": True,
|
|
1173
|
+
"ref": ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:cache"),
|
|
1174
|
+
},
|
|
1175
|
+
}],
|
|
1176
|
+
context={
|
|
1177
|
+
"location": "./app",
|
|
1178
|
+
},
|
|
1186
1179
|
push=True,
|
|
1187
|
-
registries=[
|
|
1188
|
-
address
|
|
1189
|
-
password
|
|
1190
|
-
username
|
|
1191
|
-
|
|
1180
|
+
registries=[{
|
|
1181
|
+
"address": ecr_repository.repository_url,
|
|
1182
|
+
"password": auth_token.password,
|
|
1183
|
+
"username": auth_token.user_name,
|
|
1184
|
+
}],
|
|
1192
1185
|
tags=[ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest")])
|
|
1193
1186
|
pulumi.export("ref", my_image.ref)
|
|
1194
1187
|
```
|
|
1195
1188
|
### Multi-platform image
|
|
1196
1189
|
```python
|
|
1197
1190
|
import pulumi
|
|
1198
|
-
import
|
|
1191
|
+
import pulumi_docker_build as docker_build
|
|
1199
1192
|
|
|
1200
|
-
image =
|
|
1201
|
-
context=
|
|
1202
|
-
location
|
|
1203
|
-
|
|
1193
|
+
image = docker_build.Image("image",
|
|
1194
|
+
context={
|
|
1195
|
+
"location": "app",
|
|
1196
|
+
},
|
|
1204
1197
|
platforms=[
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
]
|
|
1198
|
+
docker_build.Platform.PLAN9_AMD64,
|
|
1199
|
+
docker_build.Platform.PLAN9_386,
|
|
1200
|
+
],
|
|
1201
|
+
push=False)
|
|
1208
1202
|
```
|
|
1209
1203
|
### Registry export
|
|
1210
1204
|
```python
|
|
1211
1205
|
import pulumi
|
|
1212
|
-
import
|
|
1206
|
+
import pulumi_docker_build as docker_build
|
|
1213
1207
|
|
|
1214
|
-
image =
|
|
1215
|
-
context=
|
|
1216
|
-
location
|
|
1217
|
-
|
|
1208
|
+
image = docker_build.Image("image",
|
|
1209
|
+
context={
|
|
1210
|
+
"location": "app",
|
|
1211
|
+
},
|
|
1218
1212
|
push=True,
|
|
1219
|
-
registries=[
|
|
1220
|
-
address
|
|
1221
|
-
password
|
|
1222
|
-
username
|
|
1223
|
-
|
|
1213
|
+
registries=[{
|
|
1214
|
+
"address": "docker.io",
|
|
1215
|
+
"password": docker_hub_password,
|
|
1216
|
+
"username": "pulumibot",
|
|
1217
|
+
}],
|
|
1224
1218
|
tags=["docker.io/pulumi/pulumi:3.107.0"])
|
|
1225
1219
|
pulumi.export("ref", my_image["ref"])
|
|
1226
1220
|
```
|
|
1227
1221
|
### Caching
|
|
1228
1222
|
```python
|
|
1229
1223
|
import pulumi
|
|
1230
|
-
import
|
|
1231
|
-
|
|
1232
|
-
image =
|
|
1233
|
-
cache_from=[
|
|
1234
|
-
local
|
|
1235
|
-
src
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
cache_to=[
|
|
1239
|
-
local
|
|
1240
|
-
dest
|
|
1241
|
-
mode
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
context=
|
|
1245
|
-
location
|
|
1246
|
-
|
|
1224
|
+
import pulumi_docker_build as docker_build
|
|
1225
|
+
|
|
1226
|
+
image = docker_build.Image("image",
|
|
1227
|
+
cache_from=[{
|
|
1228
|
+
"local": {
|
|
1229
|
+
"src": "tmp/cache",
|
|
1230
|
+
},
|
|
1231
|
+
}],
|
|
1232
|
+
cache_to=[{
|
|
1233
|
+
"local": {
|
|
1234
|
+
"dest": "tmp/cache",
|
|
1235
|
+
"mode": docker_build.CacheMode.MAX,
|
|
1236
|
+
},
|
|
1237
|
+
}],
|
|
1238
|
+
context={
|
|
1239
|
+
"location": "app",
|
|
1240
|
+
},
|
|
1241
|
+
push=False)
|
|
1247
1242
|
```
|
|
1248
1243
|
### Docker Build Cloud
|
|
1249
1244
|
```python
|
|
1250
1245
|
import pulumi
|
|
1251
|
-
import
|
|
1252
|
-
|
|
1253
|
-
image =
|
|
1254
|
-
builder=
|
|
1255
|
-
name
|
|
1256
|
-
|
|
1257
|
-
context=
|
|
1258
|
-
location
|
|
1259
|
-
|
|
1260
|
-
exec_=True
|
|
1246
|
+
import pulumi_docker_build as docker_build
|
|
1247
|
+
|
|
1248
|
+
image = docker_build.Image("image",
|
|
1249
|
+
builder={
|
|
1250
|
+
"name": "cloud-builder-name",
|
|
1251
|
+
},
|
|
1252
|
+
context={
|
|
1253
|
+
"location": "app",
|
|
1254
|
+
},
|
|
1255
|
+
exec_=True,
|
|
1256
|
+
push=False)
|
|
1261
1257
|
```
|
|
1262
1258
|
### Build arguments
|
|
1263
1259
|
```python
|
|
1264
1260
|
import pulumi
|
|
1265
|
-
import
|
|
1261
|
+
import pulumi_docker_build as docker_build
|
|
1266
1262
|
|
|
1267
|
-
image =
|
|
1263
|
+
image = docker_build.Image("image",
|
|
1268
1264
|
build_args={
|
|
1269
1265
|
"SET_ME_TO_TRUE": "true",
|
|
1270
1266
|
},
|
|
1271
|
-
context=
|
|
1272
|
-
location
|
|
1273
|
-
|
|
1267
|
+
context={
|
|
1268
|
+
"location": "app",
|
|
1269
|
+
},
|
|
1270
|
+
push=False)
|
|
1274
1271
|
```
|
|
1275
1272
|
### Build target
|
|
1276
1273
|
```python
|
|
1277
1274
|
import pulumi
|
|
1278
|
-
import
|
|
1275
|
+
import pulumi_docker_build as docker_build
|
|
1279
1276
|
|
|
1280
|
-
image =
|
|
1281
|
-
context=
|
|
1282
|
-
location
|
|
1283
|
-
|
|
1277
|
+
image = docker_build.Image("image",
|
|
1278
|
+
context={
|
|
1279
|
+
"location": "app",
|
|
1280
|
+
},
|
|
1281
|
+
push=False,
|
|
1284
1282
|
target="build-me")
|
|
1285
1283
|
```
|
|
1286
1284
|
### Named contexts
|
|
1287
1285
|
```python
|
|
1288
1286
|
import pulumi
|
|
1289
|
-
import
|
|
1290
|
-
|
|
1291
|
-
image =
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
"
|
|
1295
|
-
|
|
1296
|
-
|
|
1287
|
+
import pulumi_docker_build as docker_build
|
|
1288
|
+
|
|
1289
|
+
image = docker_build.Image("image",
|
|
1290
|
+
context={
|
|
1291
|
+
"location": "app",
|
|
1292
|
+
"named": {
|
|
1293
|
+
"golang:latest": {
|
|
1294
|
+
"location": "docker-image://golang@sha256:b8e62cf593cdaff36efd90aa3a37de268e6781a2e68c6610940c48f7cdf36984",
|
|
1295
|
+
},
|
|
1296
|
+
},
|
|
1297
1297
|
},
|
|
1298
|
-
|
|
1298
|
+
push=False)
|
|
1299
1299
|
```
|
|
1300
1300
|
### Remote context
|
|
1301
1301
|
```python
|
|
1302
1302
|
import pulumi
|
|
1303
|
-
import
|
|
1303
|
+
import pulumi_docker_build as docker_build
|
|
1304
1304
|
|
|
1305
|
-
image =
|
|
1306
|
-
|
|
1307
|
-
|
|
1305
|
+
image = docker_build.Image("image",
|
|
1306
|
+
context={
|
|
1307
|
+
"location": "https://raw.githubusercontent.com/pulumi/pulumi-docker/api-types/provider/testdata/Dockerfile",
|
|
1308
|
+
},
|
|
1309
|
+
push=False)
|
|
1308
1310
|
```
|
|
1309
1311
|
### Inline Dockerfile
|
|
1310
1312
|
```python
|
|
1311
1313
|
import pulumi
|
|
1312
|
-
import
|
|
1313
|
-
|
|
1314
|
-
image =
|
|
1315
|
-
context=
|
|
1316
|
-
location
|
|
1317
|
-
|
|
1318
|
-
dockerfile=
|
|
1319
|
-
inline
|
|
1314
|
+
import pulumi_docker_build as docker_build
|
|
1315
|
+
|
|
1316
|
+
image = docker_build.Image("image",
|
|
1317
|
+
context={
|
|
1318
|
+
"location": "app",
|
|
1319
|
+
},
|
|
1320
|
+
dockerfile={
|
|
1321
|
+
"inline": \"\"\"FROM busybox
|
|
1320
1322
|
COPY hello.c ./
|
|
1321
1323
|
\"\"\",
|
|
1322
|
-
|
|
1324
|
+
},
|
|
1325
|
+
push=False)
|
|
1323
1326
|
```
|
|
1324
1327
|
### Remote context
|
|
1325
1328
|
```python
|
|
1326
1329
|
import pulumi
|
|
1327
|
-
import
|
|
1328
|
-
|
|
1329
|
-
image =
|
|
1330
|
-
context=
|
|
1331
|
-
location
|
|
1332
|
-
|
|
1333
|
-
dockerfile=
|
|
1334
|
-
location
|
|
1335
|
-
|
|
1330
|
+
import pulumi_docker_build as docker_build
|
|
1331
|
+
|
|
1332
|
+
image = docker_build.Image("image",
|
|
1333
|
+
context={
|
|
1334
|
+
"location": "https://github.com/docker-library/hello-world.git",
|
|
1335
|
+
},
|
|
1336
|
+
dockerfile={
|
|
1337
|
+
"location": "app/Dockerfile",
|
|
1338
|
+
},
|
|
1339
|
+
push=False)
|
|
1336
1340
|
```
|
|
1337
1341
|
### Local export
|
|
1338
1342
|
```python
|
|
1339
1343
|
import pulumi
|
|
1340
|
-
import
|
|
1341
|
-
|
|
1342
|
-
image =
|
|
1343
|
-
context=
|
|
1344
|
-
location
|
|
1345
|
-
|
|
1346
|
-
exports=[
|
|
1347
|
-
docker
|
|
1348
|
-
tar
|
|
1349
|
-
|
|
1350
|
-
|
|
1344
|
+
import pulumi_docker_build as docker_build
|
|
1345
|
+
|
|
1346
|
+
image = docker_build.Image("image",
|
|
1347
|
+
context={
|
|
1348
|
+
"location": "app",
|
|
1349
|
+
},
|
|
1350
|
+
exports=[{
|
|
1351
|
+
"docker": {
|
|
1352
|
+
"tar": True,
|
|
1353
|
+
},
|
|
1354
|
+
}],
|
|
1355
|
+
push=False)
|
|
1351
1356
|
```
|
|
1352
1357
|
|
|
1353
1358
|
:param str resource_name: The name of the resource.
|
|
@@ -1368,13 +1373,13 @@ class Image(pulumi.CustomResource):
|
|
|
1368
1373
|
add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
|
1369
1374
|
build_args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
1370
1375
|
build_on_preview: Optional[pulumi.Input[bool]] = None,
|
|
1371
|
-
builder: Optional[pulumi.Input[
|
|
1372
|
-
cache_from: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
1373
|
-
cache_to: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
1374
|
-
context: Optional[pulumi.Input[
|
|
1375
|
-
dockerfile: Optional[pulumi.Input[
|
|
1376
|
+
builder: Optional[pulumi.Input[Union['BuilderConfigArgs', 'BuilderConfigArgsDict']]] = None,
|
|
1377
|
+
cache_from: Optional[pulumi.Input[Sequence[pulumi.Input[Union['CacheFromArgs', 'CacheFromArgsDict']]]]] = None,
|
|
1378
|
+
cache_to: Optional[pulumi.Input[Sequence[pulumi.Input[Union['CacheToArgs', 'CacheToArgsDict']]]]] = None,
|
|
1379
|
+
context: Optional[pulumi.Input[Union['BuildContextArgs', 'BuildContextArgsDict']]] = None,
|
|
1380
|
+
dockerfile: Optional[pulumi.Input[Union['DockerfileArgs', 'DockerfileArgsDict']]] = None,
|
|
1376
1381
|
exec_: Optional[pulumi.Input[bool]] = None,
|
|
1377
|
-
exports: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
1382
|
+
exports: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ExportArgs', 'ExportArgsDict']]]]] = None,
|
|
1378
1383
|
labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
1379
1384
|
load: Optional[pulumi.Input[bool]] = None,
|
|
1380
1385
|
network: Optional[pulumi.Input['NetworkMode']] = None,
|
|
@@ -1382,9 +1387,9 @@ class Image(pulumi.CustomResource):
|
|
|
1382
1387
|
platforms: Optional[pulumi.Input[Sequence[pulumi.Input['Platform']]]] = None,
|
|
1383
1388
|
pull: Optional[pulumi.Input[bool]] = None,
|
|
1384
1389
|
push: Optional[pulumi.Input[bool]] = None,
|
|
1385
|
-
registries: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
1390
|
+
registries: Optional[pulumi.Input[Sequence[pulumi.Input[Union['RegistryArgs', 'RegistryArgsDict']]]]] = None,
|
|
1386
1391
|
secrets: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
|
|
1387
|
-
ssh: Optional[pulumi.Input[Sequence[pulumi.Input[
|
|
1392
|
+
ssh: Optional[pulumi.Input[Sequence[pulumi.Input[Union['SSHArgs', 'SSHArgsDict']]]]] = None,
|
|
1388
1393
|
tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
|
1389
1394
|
target: Optional[pulumi.Input[str]] = None,
|
|
1390
1395
|
__props__=None):
|
|
@@ -1398,6 +1403,8 @@ class Image(pulumi.CustomResource):
|
|
|
1398
1403
|
|
|
1399
1404
|
__props__.__dict__["add_hosts"] = add_hosts
|
|
1400
1405
|
__props__.__dict__["build_args"] = build_args
|
|
1406
|
+
if build_on_preview is None:
|
|
1407
|
+
build_on_preview = True
|
|
1401
1408
|
__props__.__dict__["build_on_preview"] = build_on_preview
|
|
1402
1409
|
__props__.__dict__["builder"] = builder
|
|
1403
1410
|
__props__.__dict__["cache_from"] = cache_from
|
|
@@ -1414,6 +1421,8 @@ class Image(pulumi.CustomResource):
|
|
|
1414
1421
|
__props__.__dict__["no_cache"] = no_cache
|
|
1415
1422
|
__props__.__dict__["platforms"] = platforms
|
|
1416
1423
|
__props__.__dict__["pull"] = pull
|
|
1424
|
+
if push is None and not opts.urn:
|
|
1425
|
+
raise TypeError("Missing required property 'push'")
|
|
1417
1426
|
__props__.__dict__["push"] = push
|
|
1418
1427
|
__props__.__dict__["registries"] = registries
|
|
1419
1428
|
__props__.__dict__["secrets"] = secrets
|
|
@@ -1502,20 +1511,17 @@ class Image(pulumi.CustomResource):
|
|
|
1502
1511
|
@pulumi.getter(name="buildOnPreview")
|
|
1503
1512
|
def build_on_preview(self) -> pulumi.Output[Optional[bool]]:
|
|
1504
1513
|
"""
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
Travis CI, Azure Pipelines, etc.) then it will build images during
|
|
1508
|
-
previews as a safeguard. Otherwise, if not running on CI, previews will
|
|
1509
|
-
not build images.
|
|
1510
|
-
|
|
1511
|
-
Setting this to `false` forces previews to never perform builds, and
|
|
1512
|
-
setting it to `true` will always build the image during previews.
|
|
1514
|
+
Setting this to `false` will always skip image builds during previews,
|
|
1515
|
+
and setting it to `true` will always build images during previews.
|
|
1513
1516
|
|
|
1514
1517
|
Images built during previews are never exported to registries, however
|
|
1515
1518
|
cache manifests are still exported.
|
|
1516
1519
|
|
|
1517
1520
|
On-disk Dockerfiles are always validated for syntactic correctness
|
|
1518
1521
|
regardless of this setting.
|
|
1522
|
+
|
|
1523
|
+
Defaults to `true` as a safeguard against broken images merging as part
|
|
1524
|
+
of CI pipelines.
|
|
1519
1525
|
"""
|
|
1520
1526
|
return pulumi.get(self, "build_on_preview")
|
|
1521
1527
|
|
|
@@ -1551,7 +1557,7 @@ class Image(pulumi.CustomResource):
|
|
|
1551
1557
|
@pulumi.getter
|
|
1552
1558
|
def context(self) -> pulumi.Output[Optional['outputs.BuildContext']]:
|
|
1553
1559
|
"""
|
|
1554
|
-
Build context settings.
|
|
1560
|
+
Build context settings. Defaults to the current directory.
|
|
1555
1561
|
|
|
1556
1562
|
Equivalent to Docker's `PATH | URL | -` positional argument.
|
|
1557
1563
|
"""
|
|
@@ -1700,7 +1706,7 @@ class Image(pulumi.CustomResource):
|
|
|
1700
1706
|
|
|
1701
1707
|
@property
|
|
1702
1708
|
@pulumi.getter
|
|
1703
|
-
def push(self) -> pulumi.Output[
|
|
1709
|
+
def push(self) -> pulumi.Output[bool]:
|
|
1704
1710
|
"""
|
|
1705
1711
|
When `true` the build will automatically include a `registry` export.
|
|
1706
1712
|
|