internals.go 18 KB

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