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