DockerCLI/cli/command/image
Sebastiaan van Stijn a1048523d2
Allow Dockerfile from outside build-context
Historically, the Dockerfile had to be insde the build-context, because it was
sent as part of the build-context.

3f6dc81e10
added support for passing the Dockerfile through stdin, in which case the
contents of the Dockerfile is injected into the build-context.

This patch uses the same mechanism for situations where the location of the
Dockerfile is passed, and its path is outside of the build-context.

Before this change:

    $ mkdir -p myproject/context myproject/dockerfiles && cd myproject
    $ echo "hello" > context/hello
    $ echo -e "FROM busybox\nCOPY /hello /\nRUN cat /hello" > dockerfiles/Dockerfile
    $ docker build --no-cache -f $PWD/dockerfiles/Dockerfile $PWD/context

    unable to prepare context: the Dockerfile (/Users/sebastiaan/projects/test/dockerfile-outside/myproject/dockerfiles/Dockerfile) must be within the build context

After this change:

    $ mkdir -p myproject/context myproject/dockerfiles && cd myproject
    $ echo "hello" > context/hello
    $ echo -e "FROM busybox\nCOPY /hello /\nRUN cat /hello" > dockerfiles/Dockerfile
    $ docker build --no-cache -f $PWD/dockerfiles/Dockerfile $PWD/context

    Sending build context to Docker daemon  2.607kB
    Step 1/3 : FROM busybox
     ---> 6ad733544a63
    Step 2/3 : COPY /hello /
     ---> 9a5ae1c7be9e
    Step 3/3 : RUN cat /hello
     ---> Running in 20dfef2d180f
    hello
    Removing intermediate container 20dfef2d180f
     ---> ce1748f91bb2
    Successfully built ce1748f91bb2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-02-20 16:50:49 +01:00
..
build Allow Dockerfile from outside build-context 2018-02-20 16:50:49 +01:00
testdata Use t.Run() for tests 2017-10-30 13:00:03 -04:00
build.go Allow Dockerfile from outside build-context 2018-02-20 16:50:49 +01:00
build_session.go Add nakedret linter. 2017-10-12 11:48:51 -04:00
build_test.go Allow Dockerfile from outside build-context 2018-02-20 16:50:49 +01:00
client_test.go Compress after rewriting the archive. 2017-06-29 13:18:10 -04:00
cmd.go Move credential getting functions to the ConfigFile. 2017-06-27 13:46:47 +02:00
history.go Unit tests for cli/commands/image (except build and tag) 2017-05-03 18:40:22 -07:00
history_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
import.go Update cli imports to using local package 2017-05-15 14:45:19 +02:00
import_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
inspect.go Unit tests for cli/commands/image (except build and tag) 2017-05-03 18:40:22 -07:00
inspect_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
list.go Update cli imports to using local package 2017-05-15 14:45:19 +02:00
list_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
load.go Unit tests for cli/commands/image (except build and tag) 2017-05-03 18:40:22 -07:00
load_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
prune.go Update code for upstream cobra 2017-10-25 14:49:26 -04:00
prune_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
pull.go LCOW: Add `--platform=` CLI flag to pull/create/run/build 2017-10-31 09:50:43 -07:00
pull_test.go Refactor runPull to remove second GetImageReferencesAndAuth 2017-10-10 16:32:27 -04:00
push.go trust: update existing code for new vendoring, refactor for docker trust code sharing 2017-09-25 09:34:52 -07:00
push_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
remove.go Remove: add missing eol when --force is passed 2018-01-16 09:29:53 +01:00
remove_test.go Remove: add missing eol when --force is passed 2018-01-16 09:29:53 +01:00
save.go Fast fail when save directory does not exist 2017-07-27 15:00:38 -07:00
save_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
tag.go Unit tests for cli/commands/image (except build and tag) 2017-05-03 18:40:22 -07:00
tag_test.go Use new internal testutil.ErrorContains() 2017-08-22 10:14:25 -04:00
trust.go Merge pull request #474 from jhowardmsft/jjh/apis-for-platform 2017-11-07 14:26:31 +01:00
trust_test.go Move notary to its new location 2017-10-30 17:21:41 +01:00