internals.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. package dockerfile
  2. // internals for handling commands. Covers many areas and a lot of
  3. // non-contiguous functionality. Please read the comments.
  4. import (
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "fmt"
  8. "io"
  9. "io/ioutil"
  10. "net/http"
  11. "net/url"
  12. "os"
  13. "path/filepath"
  14. "runtime"
  15. "sort"
  16. "strings"
  17. "time"
  18. "github.com/Sirupsen/logrus"
  19. "github.com/docker/docker/api"
  20. "github.com/docker/docker/builder"
  21. "github.com/docker/docker/builder/dockerfile/parser"
  22. "github.com/docker/docker/daemon"
  23. "github.com/docker/docker/image"
  24. "github.com/docker/docker/pkg/archive"
  25. "github.com/docker/docker/pkg/httputils"
  26. "github.com/docker/docker/pkg/ioutils"
  27. "github.com/docker/docker/pkg/jsonmessage"
  28. "github.com/docker/docker/pkg/progressreader"
  29. "github.com/docker/docker/pkg/streamformatter"
  30. "github.com/docker/docker/pkg/stringid"
  31. "github.com/docker/docker/pkg/stringutils"
  32. "github.com/docker/docker/pkg/system"
  33. "github.com/docker/docker/pkg/tarsum"
  34. "github.com/docker/docker/pkg/urlutil"
  35. "github.com/docker/docker/runconfig"
  36. )
  37. func (b *Builder) commit(id string, autoCmd *stringutils.StrSlice, comment string) error {
  38. if b.disableCommit {
  39. return nil
  40. }
  41. if b.image == "" && !b.noBaseImage {
  42. return fmt.Errorf("Please provide a source image with `from` prior to commit")
  43. }
  44. b.runConfig.Image = b.image
  45. if id == "" {
  46. cmd := b.runConfig.Cmd
  47. if runtime.GOOS != "windows" {
  48. b.runConfig.Cmd = stringutils.NewStrSlice("/bin/sh", "-c", "#(nop) "+comment)
  49. } else {
  50. b.runConfig.Cmd = stringutils.NewStrSlice("cmd", "/S /C", "REM (nop) "+comment)
  51. }
  52. defer func(cmd *stringutils.StrSlice) { b.runConfig.Cmd = cmd }(cmd)
  53. if hit, err := b.probeCache(); err != nil {
  54. return err
  55. } else if hit {
  56. return nil
  57. }
  58. container, err := b.create()
  59. if err != nil {
  60. return err
  61. }
  62. id = container.ID
  63. if err := container.Mount(); err != nil {
  64. return err
  65. }
  66. defer container.Unmount()
  67. }
  68. container, err := b.docker.Container(id)
  69. if err != nil {
  70. return err
  71. }
  72. // Note: Actually copy the struct
  73. autoConfig := *b.runConfig
  74. autoConfig.Cmd = autoCmd
  75. commitCfg := &daemon.ContainerCommitConfig{
  76. Author: b.maintainer,
  77. Pause: true,
  78. Config: &autoConfig,
  79. }
  80. // Commit the container
  81. image, err := b.docker.Commit(container, commitCfg)
  82. if err != nil {
  83. return err
  84. }
  85. b.docker.Retain(b.id, image.ID)
  86. b.activeImages = append(b.activeImages, image.ID)
  87. b.image = image.ID
  88. return nil
  89. }
  90. type copyInfo struct {
  91. builder.FileInfo
  92. decompress bool
  93. }
  94. func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalDecompression bool, cmdName string) error {
  95. if b.context == nil {
  96. return fmt.Errorf("No context given. Impossible to use %s", cmdName)
  97. }
  98. if len(args) < 2 {
  99. return fmt.Errorf("Invalid %s format - at least two arguments required", cmdName)
  100. }
  101. // Work in daemon-specific filepath semantics
  102. dest := filepath.FromSlash(args[len(args)-1]) // last one is always the dest
  103. b.runConfig.Image = b.image
  104. var infos []copyInfo
  105. // Loop through each src file and calculate the info we need to
  106. // do the copy (e.g. hash value if cached). Don't actually do
  107. // the copy until we've looked at all src files
  108. var err error
  109. for _, orig := range args[0 : len(args)-1] {
  110. var fi builder.FileInfo
  111. decompress := allowLocalDecompression
  112. if urlutil.IsURL(orig) {
  113. if !allowRemote {
  114. return fmt.Errorf("Source can't be a URL for %s", cmdName)
  115. }
  116. fi, err = b.download(orig)
  117. if err != nil {
  118. return err
  119. }
  120. defer os.RemoveAll(filepath.Dir(fi.Path()))
  121. decompress = false
  122. infos = append(infos, copyInfo{fi, decompress})
  123. continue
  124. }
  125. // not a URL
  126. subInfos, err := b.calcCopyInfo(cmdName, orig, allowLocalDecompression, true)
  127. if err != nil {
  128. return err
  129. }
  130. infos = append(infos, subInfos...)
  131. }
  132. if len(infos) == 0 {
  133. return fmt.Errorf("No source files were specified")
  134. }
  135. if len(infos) > 1 && !strings.HasSuffix(dest, string(os.PathSeparator)) {
  136. return fmt.Errorf("When using %s with more than one source file, the destination must be a directory and end with a /", cmdName)
  137. }
  138. // For backwards compat, if there's just one info then use it as the
  139. // cache look-up string, otherwise hash 'em all into one
  140. var srcHash string
  141. var origPaths string
  142. if len(infos) == 1 {
  143. fi := infos[0].FileInfo
  144. origPaths = fi.Name()
  145. if hfi, ok := fi.(builder.Hashed); ok {
  146. srcHash = hfi.Hash()
  147. }
  148. } else {
  149. var hashs []string
  150. var origs []string
  151. for _, info := range infos {
  152. fi := info.FileInfo
  153. origs = append(origs, fi.Name())
  154. if hfi, ok := fi.(builder.Hashed); ok {
  155. hashs = append(hashs, hfi.Hash())
  156. }
  157. }
  158. hasher := sha256.New()
  159. hasher.Write([]byte(strings.Join(hashs, ",")))
  160. srcHash = "multi:" + hex.EncodeToString(hasher.Sum(nil))
  161. origPaths = strings.Join(origs, " ")
  162. }
  163. cmd := b.runConfig.Cmd
  164. if runtime.GOOS != "windows" {
  165. b.runConfig.Cmd = stringutils.NewStrSlice("/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, srcHash, dest))
  166. } else {
  167. b.runConfig.Cmd = stringutils.NewStrSlice("cmd", "/S /C", fmt.Sprintf("REM (nop) %s %s in %s", cmdName, srcHash, dest))
  168. }
  169. defer func(cmd *stringutils.StrSlice) { b.runConfig.Cmd = cmd }(cmd)
  170. if hit, err := b.probeCache(); err != nil {
  171. return err
  172. } else if hit {
  173. return nil
  174. }
  175. container, _, err := b.docker.Create(b.runConfig, nil)
  176. if err != nil {
  177. return err
  178. }
  179. defer container.Unmount()
  180. b.tmpContainers[container.ID] = struct{}{}
  181. comment := fmt.Sprintf("%s %s in %s", cmdName, origPaths, dest)
  182. // Twiddle the destination when its a relative path - meaning, make it
  183. // relative to the WORKINGDIR
  184. if !system.IsAbs(dest) {
  185. hasSlash := strings.HasSuffix(dest, string(os.PathSeparator))
  186. dest = filepath.Join(string(os.PathSeparator), filepath.FromSlash(b.runConfig.WorkingDir), dest)
  187. // Make sure we preserve any trailing slash
  188. if hasSlash {
  189. dest += string(os.PathSeparator)
  190. }
  191. }
  192. for _, info := range infos {
  193. if err := b.docker.Copy(container, dest, info.FileInfo, info.decompress); err != nil {
  194. return err
  195. }
  196. }
  197. if err := b.commit(container.ID, cmd, comment); err != nil {
  198. return err
  199. }
  200. return nil
  201. }
  202. func (b *Builder) download(srcURL string) (fi builder.FileInfo, err error) {
  203. // get filename from URL
  204. u, err := url.Parse(srcURL)
  205. if err != nil {
  206. return
  207. }
  208. path := filepath.FromSlash(u.Path) // Ensure in platform semantics
  209. if strings.HasSuffix(path, string(os.PathSeparator)) {
  210. path = path[:len(path)-1]
  211. }
  212. parts := strings.Split(path, string(os.PathSeparator))
  213. filename := parts[len(parts)-1]
  214. if filename == "" {
  215. err = fmt.Errorf("cannot determine filename from url: %s", u)
  216. return
  217. }
  218. // Initiate the download
  219. resp, err := httputils.Download(srcURL)
  220. if err != nil {
  221. return
  222. }
  223. // Prepare file in a tmp dir
  224. tmpDir, err := ioutils.TempDir("", "docker-remote")
  225. if err != nil {
  226. return
  227. }
  228. defer func() {
  229. if err != nil {
  230. os.RemoveAll(tmpDir)
  231. }
  232. }()
  233. tmpFileName := filepath.Join(tmpDir, filename)
  234. tmpFile, err := os.OpenFile(tmpFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
  235. if err != nil {
  236. return
  237. }
  238. // Download and dump result to tmp file
  239. if _, err = io.Copy(tmpFile, progressreader.New(progressreader.Config{
  240. In: resp.Body,
  241. // TODO: make progressreader streamformatter agnostic
  242. Out: b.Stdout.(*streamformatter.StdoutFormatter).Writer,
  243. Formatter: b.Stdout.(*streamformatter.StdoutFormatter).StreamFormatter,
  244. Size: resp.ContentLength,
  245. NewLines: true,
  246. ID: "",
  247. Action: "Downloading",
  248. })); err != nil {
  249. tmpFile.Close()
  250. return
  251. }
  252. fmt.Fprintln(b.Stdout)
  253. // ignoring error because the file was already opened successfully
  254. tmpFileSt, err := tmpFile.Stat()
  255. if err != nil {
  256. return
  257. }
  258. tmpFile.Close()
  259. // Set the mtime to the Last-Modified header value if present
  260. // Otherwise just remove atime and mtime
  261. mTime := time.Time{}
  262. lastMod := resp.Header.Get("Last-Modified")
  263. if lastMod != "" {
  264. // If we can't parse it then just let it default to 'zero'
  265. // otherwise use the parsed time value
  266. if parsedMTime, err := http.ParseTime(lastMod); err == nil {
  267. mTime = parsedMTime
  268. }
  269. }
  270. if err = system.Chtimes(tmpFileName, time.Time{}, mTime); err != nil {
  271. return
  272. }
  273. // Calc the checksum, even if we're using the cache
  274. r, err := archive.Tar(tmpFileName, archive.Uncompressed)
  275. if err != nil {
  276. return
  277. }
  278. tarSum, err := tarsum.NewTarSum(r, true, tarsum.Version1)
  279. if err != nil {
  280. return
  281. }
  282. if _, err = io.Copy(ioutil.Discard, tarSum); err != nil {
  283. return
  284. }
  285. hash := tarSum.Sum(nil)
  286. r.Close()
  287. return &builder.HashedFileInfo{FileInfo: builder.PathFileInfo{FileInfo: tmpFileSt, FilePath: tmpFileName}, FileHash: hash}, nil
  288. }
  289. func (b *Builder) calcCopyInfo(cmdName, origPath string, allowLocalDecompression, allowWildcards bool) ([]copyInfo, error) {
  290. // Work in daemon-specific OS filepath semantics
  291. origPath = filepath.FromSlash(origPath)
  292. if origPath != "" && origPath[0] == os.PathSeparator && len(origPath) > 1 {
  293. origPath = origPath[1:]
  294. }
  295. origPath = strings.TrimPrefix(origPath, "."+string(os.PathSeparator))
  296. // Deal with wildcards
  297. if allowWildcards && containsWildcards(origPath) {
  298. var copyInfos []copyInfo
  299. if err := b.context.Walk("", func(path string, info builder.FileInfo, err error) error {
  300. if err != nil {
  301. return err
  302. }
  303. if info.Name() == "" {
  304. // Why are we doing this check?
  305. return nil
  306. }
  307. if match, _ := filepath.Match(origPath, path); !match {
  308. return nil
  309. }
  310. // Note we set allowWildcards to false in case the name has
  311. // a * in it
  312. subInfos, err := b.calcCopyInfo(cmdName, path, allowLocalDecompression, false)
  313. if err != nil {
  314. return err
  315. }
  316. copyInfos = append(copyInfos, subInfos...)
  317. return nil
  318. }); err != nil {
  319. return nil, err
  320. }
  321. return copyInfos, nil
  322. }
  323. // Must be a dir or a file
  324. fi, err := b.context.Stat(origPath)
  325. if err != nil {
  326. return nil, err
  327. }
  328. copyInfos := []copyInfo{{FileInfo: fi, decompress: allowLocalDecompression}}
  329. hfi, handleHash := fi.(builder.Hashed)
  330. if !handleHash {
  331. return copyInfos, nil
  332. }
  333. // Deal with the single file case
  334. if !fi.IsDir() {
  335. hfi.SetHash("file:" + hfi.Hash())
  336. return copyInfos, nil
  337. }
  338. // Must be a dir
  339. var subfiles []string
  340. b.context.Walk(origPath, func(path string, info builder.FileInfo, err error) error {
  341. if err != nil {
  342. return err
  343. }
  344. // we already checked handleHash above
  345. subfiles = append(subfiles, info.(builder.Hashed).Hash())
  346. return nil
  347. })
  348. sort.Strings(subfiles)
  349. hasher := sha256.New()
  350. hasher.Write([]byte(strings.Join(subfiles, ",")))
  351. hfi.SetHash("dir:" + hex.EncodeToString(hasher.Sum(nil)))
  352. return copyInfos, nil
  353. }
  354. func containsWildcards(name string) bool {
  355. for i := 0; i < len(name); i++ {
  356. ch := name[i]
  357. if ch == '\\' {
  358. i++
  359. } else if ch == '*' || ch == '?' || ch == '[' {
  360. return true
  361. }
  362. }
  363. return false
  364. }
  365. func (b *Builder) processImageFrom(img *image.Image) error {
  366. b.image = img.ID
  367. if img.Config != nil {
  368. b.runConfig = img.Config
  369. }
  370. // The default path will be blank on Windows (set by HCS)
  371. if len(b.runConfig.Env) == 0 && daemon.DefaultPathEnv != "" {
  372. b.runConfig.Env = append(b.runConfig.Env, "PATH="+daemon.DefaultPathEnv)
  373. }
  374. // Process ONBUILD triggers if they exist
  375. if nTriggers := len(b.runConfig.OnBuild); nTriggers != 0 {
  376. word := "trigger"
  377. if nTriggers > 1 {
  378. word = "triggers"
  379. }
  380. fmt.Fprintf(b.Stderr, "# Executing %d build %s...\n", nTriggers, word)
  381. }
  382. // Copy the ONBUILD triggers, and remove them from the config, since the config will be committed.
  383. onBuildTriggers := b.runConfig.OnBuild
  384. b.runConfig.OnBuild = []string{}
  385. // parse the ONBUILD triggers by invoking the parser
  386. for _, step := range onBuildTriggers {
  387. ast, err := parser.Parse(strings.NewReader(step))
  388. if err != nil {
  389. return err
  390. }
  391. for i, n := range ast.Children {
  392. switch strings.ToUpper(n.Value) {
  393. case "ONBUILD":
  394. return fmt.Errorf("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed")
  395. case "MAINTAINER", "FROM":
  396. return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", n.Value)
  397. }
  398. if err := b.dispatch(i, n); err != nil {
  399. return err
  400. }
  401. }
  402. }
  403. return nil
  404. }
  405. // probeCache checks if `b.docker` implements builder.ImageCache and image-caching
  406. // is enabled (`b.UseCache`).
  407. // If so attempts to look up the current `b.image` and `b.runConfig` pair with `b.docker`.
  408. // If an image is found, probeCache returns `(true, nil)`.
  409. // If no image is found, it returns `(false, nil)`.
  410. // If there is any error, it returns `(false, err)`.
  411. func (b *Builder) probeCache() (bool, error) {
  412. c, ok := b.docker.(builder.ImageCache)
  413. if !ok || !b.UseCache || b.cacheBusted {
  414. return false, nil
  415. }
  416. cache, err := c.GetCachedImage(b.image, b.runConfig)
  417. if err != nil {
  418. return false, err
  419. }
  420. if len(cache) == 0 {
  421. logrus.Debugf("[BUILDER] Cache miss: %s", b.runConfig.Cmd)
  422. b.cacheBusted = true
  423. return false, nil
  424. }
  425. fmt.Fprintf(b.Stdout, " ---> Using cache\n")
  426. logrus.Debugf("[BUILDER] Use cached version: %s", b.runConfig.Cmd)
  427. b.image = string(cache)
  428. // TODO: remove once Commit can take a tag parameter.
  429. b.docker.Retain(b.id, b.image)
  430. b.activeImages = append(b.activeImages, b.image)
  431. return true, nil
  432. }
  433. func (b *Builder) create() (*daemon.Container, error) {
  434. if b.image == "" && !b.noBaseImage {
  435. return nil, fmt.Errorf("Please provide a source image with `from` prior to run")
  436. }
  437. b.runConfig.Image = b.image
  438. // TODO: why not embed a hostconfig in builder?
  439. hostConfig := &runconfig.HostConfig{
  440. CPUShares: b.CPUShares,
  441. CPUPeriod: b.CPUPeriod,
  442. CPUQuota: b.CPUQuota,
  443. CpusetCpus: b.CPUSetCpus,
  444. CpusetMems: b.CPUSetMems,
  445. CgroupParent: b.CgroupParent,
  446. Memory: b.Memory,
  447. MemorySwap: b.MemorySwap,
  448. Ulimits: b.Ulimits,
  449. Isolation: b.Isolation,
  450. }
  451. config := *b.runConfig
  452. // Create the container
  453. c, warnings, err := b.docker.Create(b.runConfig, hostConfig)
  454. if err != nil {
  455. return nil, err
  456. }
  457. defer c.Unmount()
  458. for _, warning := range warnings {
  459. fmt.Fprintf(b.Stdout, " ---> [Warning] %s\n", warning)
  460. }
  461. b.tmpContainers[c.ID] = struct{}{}
  462. fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID))
  463. if config.Cmd.Len() > 0 {
  464. // override the entry point that may have been picked up from the base image
  465. s := config.Cmd.Slice()
  466. c.Path = s[0]
  467. c.Args = s[1:]
  468. }
  469. return c, nil
  470. }
  471. func (b *Builder) run(c *daemon.Container) error {
  472. var errCh chan error
  473. if b.Verbose {
  474. errCh = c.Attach(nil, b.Stdout, b.Stderr)
  475. }
  476. //start the container
  477. if err := c.Start(); err != nil {
  478. return err
  479. }
  480. finished := make(chan struct{})
  481. defer close(finished)
  482. go func() {
  483. select {
  484. case <-b.cancelled:
  485. logrus.Debugln("Build cancelled, killing and removing container:", c.ID)
  486. c.Kill()
  487. b.removeContainer(c.ID)
  488. case <-finished:
  489. }
  490. }()
  491. if b.Verbose {
  492. // Block on reading output from container, stop on err or chan closed
  493. if err := <-errCh; err != nil {
  494. return err
  495. }
  496. }
  497. // Wait for it to finish
  498. if ret, _ := c.WaitStop(-1 * time.Second); ret != 0 {
  499. // TODO: change error type, because jsonmessage.JSONError assumes HTTP
  500. return &jsonmessage.JSONError{
  501. Message: fmt.Sprintf("The command '%s' returned a non-zero code: %d", b.runConfig.Cmd.ToString(), ret),
  502. Code: ret,
  503. }
  504. }
  505. return nil
  506. }
  507. func (b *Builder) removeContainer(c string) error {
  508. rmConfig := &daemon.ContainerRmConfig{
  509. ForceRemove: true,
  510. RemoveVolume: true,
  511. }
  512. if err := b.docker.Remove(c, rmConfig); err != nil {
  513. fmt.Fprintf(b.Stdout, "Error removing intermediate container %s: %v\n", stringid.TruncateID(c), err)
  514. return err
  515. }
  516. return nil
  517. }
  518. func (b *Builder) clearTmp() {
  519. for c := range b.tmpContainers {
  520. if err := b.removeContainer(c); err != nil {
  521. return
  522. }
  523. delete(b.tmpContainers, c)
  524. fmt.Fprintf(b.Stdout, "Removing intermediate container %s\n", stringid.TruncateID(c))
  525. }
  526. }
  527. // readDockerfile reads a Dockerfile from the current context.
  528. func (b *Builder) readDockerfile() error {
  529. // If no -f was specified then look for 'Dockerfile'. If we can't find
  530. // that then look for 'dockerfile'. If neither are found then default
  531. // back to 'Dockerfile' and use that in the error message.
  532. if b.DockerfileName == "" {
  533. b.DockerfileName = api.DefaultDockerfileName
  534. if _, err := b.context.Stat(b.DockerfileName); os.IsNotExist(err) {
  535. lowercase := strings.ToLower(b.DockerfileName)
  536. if _, err := b.context.Stat(lowercase); err == nil {
  537. b.DockerfileName = lowercase
  538. }
  539. }
  540. }
  541. f, err := b.context.Open(b.DockerfileName)
  542. if err != nil {
  543. if os.IsNotExist(err) {
  544. return fmt.Errorf("Cannot locate specified Dockerfile: %s", b.DockerfileName)
  545. }
  546. return err
  547. }
  548. if f, ok := f.(*os.File); ok {
  549. // ignoring error because Open already succeeded
  550. fi, err := f.Stat()
  551. if err != nil {
  552. return fmt.Errorf("Unexpected error reading Dockerfile: %v", err)
  553. }
  554. if fi.Size() == 0 {
  555. return fmt.Errorf("The Dockerfile (%s) cannot be empty", b.DockerfileName)
  556. }
  557. }
  558. b.dockerfile, err = parser.Parse(f)
  559. f.Close()
  560. if err != nil {
  561. return err
  562. }
  563. // After the Dockerfile has been parsed, we need to check the .dockerignore
  564. // file for either "Dockerfile" or ".dockerignore", and if either are
  565. // present then erase them from the build context. These files should never
  566. // have been sent from the client but we did send them to make sure that
  567. // we had the Dockerfile to actually parse, and then we also need the
  568. // .dockerignore file to know whether either file should be removed.
  569. // Note that this assumes the Dockerfile has been read into memory and
  570. // is now safe to be removed.
  571. if dockerIgnore, ok := b.context.(builder.DockerIgnoreContext); ok {
  572. dockerIgnore.Process([]string{b.DockerfileName})
  573. }
  574. return nil
  575. }
  576. // determine if build arg is part of built-in args or user
  577. // defined args in Dockerfile at any point in time.
  578. func (b *Builder) isBuildArgAllowed(arg string) bool {
  579. if _, ok := BuiltinAllowedBuildArgs[arg]; ok {
  580. return true
  581. }
  582. if _, ok := b.allowedBuildArgs[arg]; ok {
  583. return true
  584. }
  585. return false
  586. }