mirror of https://github.com/docker/docs.git
Merge pull request #874 from fsouza/fix-build-newline
- Builder: don't ignore last line in Dockerfile when it doesn't end with \n
This commit is contained in:
commit
0e6ec57996
|
@ -313,11 +313,12 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
|
|||
for {
|
||||
line, err := file.ReadString('\n')
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
if err == io.EOF && line == "" {
|
||||
break
|
||||
}
|
||||
} else if err != io.EOF {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
line = strings.Replace(strings.TrimSpace(line), " ", " ", 1)
|
||||
// Skip comments and empty line
|
||||
if len(line) == 0 || line[0] == '#' {
|
||||
|
|
|
@ -15,7 +15,17 @@ run sh -c 'echo root:testpass > /tmp/passwd'
|
|||
run mkdir -p /var/run/sshd
|
||||
`
|
||||
|
||||
const DockerfileNoNewLine = `
|
||||
# VERSION 0.1
|
||||
# DOCKER-VERSION 0.2
|
||||
|
||||
from ` + unitTestImageName + `
|
||||
run sh -c 'echo root:testpass > /tmp/passwd'
|
||||
run mkdir -p /var/run/sshd`
|
||||
|
||||
func TestBuild(t *testing.T) {
|
||||
dockerfiles := []string{Dockerfile, DockerfileNoNewLine}
|
||||
for _, Dockerfile := range dockerfiles {
|
||||
runtime, err := newTestRuntime()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -69,4 +79,5 @@ func TestBuild(t *testing.T) {
|
|||
if string(output) != "/var/run/sshd\n" {
|
||||
t.Fatal("/var/run/sshd has not been created")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue