Skip to content

Commit

Permalink
Add examples for labels and secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Feb 21, 2024
1 parent d2de55a commit 9780073
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/buildx/csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,38 @@
},
});

var secrets = new Docker.Buildx.Image("secrets", new()
{
Dockerfile = new Docker.Buildx.Inputs.DockerfileArgs
{
Location = "app/Dockerfile.secrets",
},
Context = new Docker.Buildx.Inputs.BuildContextArgs
{
Location = "app",
},
Secrets =
{
{ "password", "hunter2" },
},
});

var labels = new Docker.Buildx.Image("labels", new()
{
Dockerfile = new Docker.Buildx.Inputs.DockerfileArgs
{
Location = "app/Dockerfile.generic",
},
Context = new Docker.Buildx.Inputs.BuildContextArgs
{
Location = "app",
},
Labels =
{
{ "description", "This image will get a descriptive label 👍" },
},
});

var targets = new Docker.Buildx.Image("targets", new()
{
Dockerfile = new Docker.Buildx.Inputs.DockerfileArgs
Expand Down
28 changes: 28 additions & 0 deletions examples/buildx/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,34 @@ func main() {
if err != nil {
return err
}
_, err = buildx.NewImage(ctx, "secrets", &buildx.ImageArgs{
Dockerfile: &buildx.DockerfileArgs{
Location: pulumi.String("app/Dockerfile.secrets"),
},
Context: &buildx.BuildContextArgs{
Location: pulumi.String("app"),
},
Secrets: pulumi.StringMap{
"password": pulumi.String("hunter2"),
},
})
if err != nil {
return err
}
_, err = buildx.NewImage(ctx, "labels", &buildx.ImageArgs{
Dockerfile: &buildx.DockerfileArgs{
Location: pulumi.String("app/Dockerfile.generic"),
},
Context: &buildx.BuildContextArgs{
Location: pulumi.String("app"),
},
Labels: pulumi.StringMap{
"description": pulumi.String("This image will get a descriptive label 👍"),
},
})
if err != nil {
return err
}
_, err = buildx.NewImage(ctx, "targets", &buildx.ImageArgs{
Dockerfile: &buildx.DockerfileArgs{
Location: pulumi.String("app/Dockerfile.targets"),
Expand Down
20 changes: 20 additions & 0 deletions examples/buildx/java/src/main/java/generated_program/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ public static void stack(Context ctx) {
.buildArgs(Map.of("SET_ME_TO_TRUE", "true"))
.build());

var secrets = new Image("secrets", ImageArgs.builder()
.dockerfile(DockerfileArgs.builder()
.location("app/Dockerfile.secrets")
.build())
.context(BuildContextArgs.builder()
.location("app")
.build())
.secrets(Map.of("password", "hunter2"))
.build());

var labels = new Image("labels", ImageArgs.builder()
.dockerfile(DockerfileArgs.builder()
.location("app/Dockerfile.generic")
.build())
.context(BuildContextArgs.builder()
.location("app")
.build())
.labels(Map.of("description", "This image will get a descriptive label 👍"))
.build());

var targets = new Image("targets", ImageArgs.builder()
.dockerfile(DockerfileArgs.builder()
.location("app/Dockerfile.targets")
Expand Down
20 changes: 20 additions & 0 deletions examples/buildx/py/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@
build_args={
"SET_ME_TO_TRUE": "true",
})
secrets = docker.buildx.Image("secrets",
dockerfile=docker.buildx.DockerfileArgs(
location="app/Dockerfile.secrets",
),
context=docker.buildx.BuildContextArgs(
location="app",
),
secrets={
"password": "hunter2",
})
labels = docker.buildx.Image("labels",
dockerfile=docker.buildx.DockerfileArgs(
location="app/Dockerfile.generic",
),
context=docker.buildx.BuildContextArgs(
location="app",
),
labels={
"description": "This image will get a descriptive label 👍",
})
targets = docker.buildx.Image("targets",
dockerfile=docker.buildx.DockerfileArgs(
location="app/Dockerfile.targets",
Expand Down
22 changes: 22 additions & 0 deletions examples/buildx/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ const buildArgs = new docker.buildx.Image("buildArgs", {
SET_ME_TO_TRUE: "true",
},
});
const secrets = new docker.buildx.Image("secrets", {
dockerfile: {
location: "app/Dockerfile.secrets",
},
context: {
location: "app",
},
secrets: {
password: "hunter2",
},
});
const labels = new docker.buildx.Image("labels", {
dockerfile: {
location: "app/Dockerfile.generic",
},
context: {
location: "app",
},
labels: {
description: "This image will get a descriptive label 👍",
},
});
const targets = new docker.buildx.Image("targets", {
dockerfile: {
location: "app/Dockerfile.targets",
Expand Down
22 changes: 22 additions & 0 deletions examples/buildx/yaml/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ resources:
buildArgs:
SET_ME_TO_TRUE: "true"

# PASSWORD=hunter2 docker buildx build -f app/Dockerfile.secrets --secret id=password,env=PASSWORD app
secrets:
type: docker:buildx/image:Image
properties:
dockerfile:
location: "app/Dockerfile.secrets"
context:
location: "app"
secrets:
password: hunter2

# docker buildx build -f app/Dockerfile.generic --label "description=This image will get a descriptive label 👍" app
labels:
type: docker:buildx/image:Image
properties:
dockerfile:
location: "app/Dockerfile.generic"
context:
location: "app"
labels:
description: "This image will get a descriptive label 👍"

# docker buildx build -f app/Dockerfile.targets --target build-me --target also-build-me app
targets:
type: docker:buildx/image:Image
Expand Down

0 comments on commit 9780073

Please sign in to comment.