0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-22 00:00:40 +00:00

fix: add option to set additional build contexts (#116)

This commit is contained in:
Robert Kaussow 2022-07-24 12:48:02 +02:00 committed by GitHub
parent 734b782608
commit b08866cc0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 19 deletions

View File

@ -89,6 +89,11 @@ properties:
type: string type: string
required: false required: false
named_context:
description: Set additional named [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., name=path).
type: list
required: false
tags: tags:
description: Set repository tags to use for the image. Tags can also be loaded from a `.tags` file. description: Set repository tags to use for the image. Tags can also be loaded from a `.tags` file.
defaultValue: latest defaultValue: latest

View File

@ -128,6 +128,13 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
Destination: &settings.Build.Context, Destination: &settings.Build.Context,
Category: category, Category: category,
}, },
&cli.StringSliceFlag{
Name: "named-context",
EnvVars: []string{"PLUGIN_NAMED_CONTEXT"},
Usage: "additional named build context",
Destination: &settings.Build.NamedContext,
Category: category,
},
&cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "tags", Name: "tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"}, EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},

View File

@ -117,6 +117,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd {
if build.Output != "" { if build.Output != "" {
args = append(args, "--output", build.Output) args = append(args, "--output", build.Output)
} }
for _, arg := range build.NamedContext.Value() {
args = append(args, "--build-context", arg)
}
if len(build.Platforms.Value()) > 0 { if len(build.Platforms.Value()) > 0 {
args = append(args, "--platform", strings.Join(build.Platforms.Value(), ",")) args = append(args, "--platform", strings.Join(build.Platforms.Value(), ","))

View File

@ -59,6 +59,7 @@ type Build struct {
AddHost cli.StringSlice // Docker build add-host AddHost cli.StringSlice // Docker build add-host
Quiet bool // Docker build quiet Quiet bool // Docker build quiet
Output string // Docker build output folder Output string // Docker build output folder
NamedContext cli.StringSlice // Docker build named context
} }
// Settings for the Plugin. // Settings for the Plugin.