Skip to content

Commit

Permalink
Fix example (#1152)
Browse files Browse the repository at this point in the history
Fixes an example (thanks @MitchellGerdisch!) and adds a note pointing
to the new Docker Build provider.

Fixes #1150.
  • Loading branch information
blampe authored Jun 24, 2024
1 parent f78e67b commit c2158bc
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 14 deletions.
2 changes: 1 addition & 1 deletion provider/cmd/pulumi-resource-docker/schema.json

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions provider/pkg/docs-gen/examples/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,13 @@ const myAppImage = new docker.Image("my-app-image", {
images: [pulumi.interpolate`${ecrRepository.repositoryUrl}:latest`],
},
context: "app/",
dockerfile: "Dockerfile",
dockerfile: "app/Dockerfile",
},
imageName: pulumi.interpolate`${ecrRepository.repositoryUrl}:latest`,
registry: {
password: pulumi.secret(authToken.apply(authToken => authToken.password)),
server: ecrRepository.repositoryUrl,
username: authToken.apply(authToken => authToken.userName),
},
});
export const imageName = myAppImage.imageName;
Expand All @@ -329,12 +330,13 @@ my_app_image = docker.Image("my-app-image",
images=[ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest")],
),
context="app/",
dockerfile="Dockerfile",
dockerfile="app/Dockerfile",
),
image_name=ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest"),
registry=docker.RegistryArgs(
password=pulumi.Output.secret(auth_token.password),
server=ecr_repository.repository_url,
username=auth_token.user_name,
))
pulumi.export("imageName", my_app_image.image_name)
```
Expand Down Expand Up @@ -373,13 +375,14 @@ return await Deployment.RunAsync(() =>
},
},
Context = "app/",
Dockerfile = "Dockerfile",
Dockerfile = "app/Dockerfile",
},
ImageName = ecrRepository.RepositoryUrl.Apply(repositoryUrl => $"{repositoryUrl}:latest"),
Registry = new Docker.Inputs.RegistryArgs
{
Password = Output.CreateSecret(authToken.Apply(getAuthorizationTokenResult => getAuthorizationTokenResult.Password)),
Server = ecrRepository.RepositoryUrl,
Username = authToken.Apply(getAuthorizationTokenResult => getAuthorizationTokenResult.UserName),
},
});

Expand Down Expand Up @@ -425,7 +428,7 @@ func main() {
},
},
Context: pulumi.String("app/"),
Dockerfile: pulumi.String("Dockerfile"),
Dockerfile: pulumi.String("app/Dockerfile"),
},
ImageName: ecrRepository.RepositoryUrl.ApplyT(func(repositoryUrl string) (string, error) {
return fmt.Sprintf("%v:latest", repositoryUrl), nil
Expand All @@ -435,6 +438,9 @@ func main() {
return &authToken.Password, nil
}).(pulumi.StringPtrOutput)).(pulumi.StringOutput),
Server: ecrRepository.RepositoryUrl,
Username: authToken.ApplyT(func(authToken ecr.GetAuthorizationTokenResult) (*string, error) {
return &authToken.UserName, nil
}).(pulumi.StringPtrOutput),
},
})
if err != nil {
Expand Down Expand Up @@ -467,12 +473,13 @@ resources:
images:
- ${ecr-repository.repositoryUrl}:latest
context: app/
dockerfile: Dockerfile
dockerfile: app/Dockerfile
imageName: ${ecr-repository.repositoryUrl}:latest
registry:
password:
fn::secret: ${authToken.password}
server: ${ecr-repository.repositoryUrl}
username: ${authToken.userName}
type: docker:Image
runtime: yaml
variables:
Expand Down Expand Up @@ -523,12 +530,13 @@ public class App {
.images(ecrRepository.repositoryUrl().applyValue(repositoryUrl -> String.format("%s:latest", repositoryUrl)))
.build())
.context("app/")
.dockerfile("Dockerfile")
.dockerfile("app/Dockerfile")
.build())
.imageName(ecrRepository.repositoryUrl().applyValue(repositoryUrl -> String.format("%s:latest", repositoryUrl)))
.registry(RegistryArgs.builder()
.password(Output.ofSecret(authToken.applyValue(getAuthorizationTokenResult -> getAuthorizationTokenResult).applyValue(authToken -> authToken.applyValue(getAuthorizationTokenResult -> getAuthorizationTokenResult.password()))))
.server(ecrRepository.repositoryUrl())
.username(authToken.applyValue(getAuthorizationTokenResult -> getAuthorizationTokenResult).applyValue(authToken -> authToken.applyValue(getAuthorizationTokenResult -> getAuthorizationTokenResult.userName())))
.build())
.build());

Expand Down
3 changes: 2 additions & 1 deletion provider/pkg/docs-gen/examples/yaml/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ resources:
properties:
imageName: ${ecr-repository.repositoryUrl}:latest
build:
dockerfile: Dockerfile
dockerfile: app/Dockerfile
context: app/
args:
BUILDKIT_INLINE_CACHE: "1"
cacheFrom:
images:
- ${ecr-repository.repositoryUrl}:latest
registry:
username: ${authToken.userName}
server: ${ecr-repository.repositoryUrl}
password:
fn::secret: ${authToken.password}
Expand Down
4 changes: 4 additions & 0 deletions provider/pkg/docs-gen/image-description.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
`Image` builds a Docker image and pushes it Docker and OCI compatible registries.
This resource enables running Docker builds as part of a Pulumi deployment.

Note: We recommend you migrate your images to the more modern [Docker
Build](https://www.pulumi.com/registry/packages/docker-build/) provider to get
the best possible support, features, and performance.

Note: This resource does not delete tags, locally or remotely, when destroyed.

## Image name
Expand Down
7 changes: 6 additions & 1 deletion sdk/dotnet/Image.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion sdk/go/docker/image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion sdk/java/src/main/java/com/pulumi/docker/Image.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion sdk/nodejs/image.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions sdk/python/pulumi_docker/image.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c2158bc

Please sign in to comment.