From fd78128870b78c282b65976cfff100c4101569b1 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 10 Jan 2014 14:37:07 -0700 Subject: [PATCH] Add support for `RUN [""]` in Dockerfiles for greater specificity in what is actually executed Docker-DCO-1.1-Signed-off-by: Andrew Page (github: tianon) --- buildfile.go | 2 +- integration/buildfile_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/buildfile.go b/buildfile.go index de03e5879f..5071070216 100644 --- a/buildfile.go +++ b/buildfile.go @@ -124,7 +124,7 @@ func (b *buildFile) CmdRun(args string) error { if b.image == "" { return fmt.Errorf("Please provide a source image with `from` prior to run") } - config, _, _, err := ParseRun([]string{b.image, "/bin/sh", "-c", args}, nil) + config, _, _, err := ParseRun(append([]string{b.image}, b.buildCmdFromJson(args)...), nil) if err != nil { return err } diff --git a/integration/buildfile_test.go b/integration/buildfile_test.go index 5dd403274e..b7cbebd402 100644 --- a/integration/buildfile_test.go +++ b/integration/buildfile_test.go @@ -223,6 +223,31 @@ run [ "$(cat /bar/withfile)" = "test2" ] }, nil, }, + + // JSON! + { + ` +FROM {IMAGE} +RUN ["/bin/echo","hello","world"] +CMD ["/bin/true"] +ENTRYPOINT ["/bin/echo","your command -->"] +`, + nil, + nil, + }, + { + ` +FROM {IMAGE} +ADD test /test +RUN ["chmod","+x","/test"] +RUN ["/test"] +RUN [ "$(cat /testfile)" = 'test!' ] +`, + [][2]string{ + {"test", "#!/bin/sh\necho 'test!' > /testfile"}, + }, + nil, + }, } // FIXME: test building with 2 successive overlapping ADD commands