mirror of https://github.com/docker/compose.git
Adding compose build e2e test
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
a95a76291b
commit
c806b75940
|
@ -103,6 +103,42 @@ func TestLocalComposeUp(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestLocalComposeBuild(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
t.Run("build named and unnamed images", func(t *testing.T) {
|
||||
//ensure local test run does not reuse previously build image
|
||||
c.RunDockerOrExitError("rmi", "build-test_nginx")
|
||||
c.RunDockerOrExitError("rmi", "custom-nginx")
|
||||
|
||||
res := c.RunDockerCmd("compose", "build", "--workdir", "fixtures/build-test")
|
||||
|
||||
res.Assert(t, icmd.Expected{Out: "COPY static /usr/share/nginx/html"})
|
||||
c.RunDockerCmd("image", "inspect", "build-test_nginx")
|
||||
c.RunDockerCmd("image", "inspect", "custom-nginx")
|
||||
})
|
||||
|
||||
t.Run("build as part of up", func(t *testing.T) {
|
||||
c.RunDockerOrExitError("rmi", "build-test_nginx")
|
||||
c.RunDockerOrExitError("rmi", "custom-nginx")
|
||||
|
||||
res := c.RunDockerCmd("compose", "up", "-d", "--workdir", "fixtures/build-test")
|
||||
|
||||
res.Assert(t, icmd.Expected{Out: "COPY static /usr/share/nginx/html"})
|
||||
|
||||
output := HTTPGetWithRetry(t, "http://localhost:8070", http.StatusOK, 2*time.Second, 20*time.Second)
|
||||
assert.Assert(t, strings.Contains(output, "Hello from Nginx container"))
|
||||
|
||||
c.RunDockerCmd("image", "inspect", "build-test_nginx")
|
||||
c.RunDockerCmd("image", "inspect", "custom-nginx")
|
||||
})
|
||||
|
||||
t.Run("cleanup build project", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "down", "--workdir", "fixtures/build-test")
|
||||
c.RunDockerCmd("rmi", "build-test_nginx")
|
||||
c.RunDockerCmd("rmi", "custom-nginx")
|
||||
})
|
||||
}
|
||||
func TestLocalComposeVolume(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
|
@ -127,7 +163,7 @@ func TestLocalComposeVolume(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("cleanup volume project", func(t *testing.T) {
|
||||
_ = c.RunDockerCmd("compose", "down", "--project-name", projectName)
|
||||
_ = c.RunDockerCmd("volume", "rm", projectName+"_staticVol")
|
||||
c.RunDockerCmd("compose", "down", "--project-name", projectName)
|
||||
c.RunDockerCmd("volume", "rm", projectName+"_staticVol")
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
services:
|
||||
nginx:
|
||||
build: nginx-build
|
||||
ports:
|
||||
- 8070:80
|
||||
|
||||
nginx2:
|
||||
build: nginx-build
|
||||
image: custom-nginx
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM nginx
|
||||
|
||||
COPY static /usr/share/nginx/html
|
|
@ -0,0 +1,10 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Docker Nginx</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Hello from Nginx container</h2>
|
||||
</body>
|
||||
</html>
|
|
@ -12,4 +12,4 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM nginx
|
||||
FROM nginx
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
<body>
|
||||
<h2>Hello from Nginx container</h2>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue