Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #32 from geekuillaume/cache-settings
Browse files Browse the repository at this point in the history
Add cacheFrom and cacheTo settings
  • Loading branch information
benesch authored Jan 9, 2023
2 parents c8a3197 + 04b8c92 commit 1959c4f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/pulumi-resource-docker-buildkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,21 @@ func (k *dockerBuildkitProvider) dockerBuild(
platforms = append(platforms, v.StringValue())
}

cacheFrom := name
if !inputs["cacheFrom"].IsNull() {
index = inputs["cacheFrom"]
}

cacheTo := "type=inline"
if !inputs["cacheTo"].IsNull() {
index = inputs["cacheTo"]
}

args := []string{
"buildx", "build",
"--platform", strings.Join(platforms, ","),
"--cache-from", name,
"--cache-to", "type=inline",
"--cache-from", cacheFrom,
"--cache-to", cacheTo,
"-f", filepath.Join(context, dockerfile),
"--target", target,
"-t", name, "--push",
Expand Down Expand Up @@ -325,6 +335,8 @@ func (k *dockerBuildkitProvider) dockerBuild(
"contextDigest": contextDigest,
"repoDigest": repoDigest,
"registryServer": registry["server"].StringValue(),
"cacheFrom": cacheFrom,
"cacheTo": cacheTo,
}
if buildArgs != nil {
outputs["args"] = buildArgs
Expand Down
16 changes: 16 additions & 0 deletions cmd/pulumi-sdkgen-docker-buildkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ func run(version string) error {
Description: "The name of the target stage to build in the Dockerfile.",
TypeSpec: schema.TypeSpec{Type: "string"},
},
"cacheFrom": {
Description: "Value for --cache-from when executing docker buildx, default to image name",
TypeSpec: schema.TypeSpec{Type: "string"},
},
"cacheTo": {
Description: "Value for --cache-to when executing docker buildx, default to type=inline",
TypeSpec: schema.TypeSpec{Type: "string"},
},
},
Required: []string{
"dockerfile", "context", "name", "platforms",
Expand Down Expand Up @@ -128,6 +136,14 @@ func run(version string) error {
TypeSpec: schema.TypeSpec{Type: "string"},
Default: "",
},
"cacheFrom": {
Description: "Value for --cache-from when executing docker buildx, default to image name",
TypeSpec: schema.TypeSpec{Type: "string"},
},
"cacheTo": {
Description: "Value for --cache-to when executing docker buildx, default to type=inline",
TypeSpec: schema.TypeSpec{Type: "string"},
},
"args": {
Description: "The build arguments.",
TypeSpec: schema.TypeSpec{
Expand Down

0 comments on commit 1959c4f

Please sign in to comment.