Merge pull request #438 from dubo-dubon-duponey/build

Support for target & hosts (#DockerBuild)
This commit is contained in:
Andrea Luzzardi 2021-05-10 18:12:10 -07:00 committed by GitHub
commit 9f5dfacbbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -842,6 +842,32 @@ func dockerBuildOpts(op *compiler.Value) (map[string]string, error) {
opts["filename"] = filename
}
if target := op.Lookup("target"); target.Exists() {
tgr, err := target.String()
if err != nil {
return nil, err
}
opts["target"] = tgr
}
if hosts := op.Lookup("hosts"); hosts.Exists() {
p := []string{}
fields, err := hosts.Fields()
if err != nil {
return nil, err
}
for _, host := range fields {
s, err := host.Value.String()
if err != nil {
return nil, err
}
p = append(p, host.Label()+"="+s)
}
if len(p) > 0 {
opts["add-hosts"] = strings.Join(p, ",")
}
}
if buildArgs := op.Lookup("buildArg"); buildArgs.Exists() {
fields, err := buildArgs.Fields()
if err != nil {

View File

@ -92,6 +92,8 @@ package op
platforms?: [...string]
buildArg?: [string]: string
label?: [string]: string
target?: string
hosts?: [string]: string
}
#WriteFile: {