mirror of
https://github.com/docker/compose.git
synced 2025-07-22 13:14:29 +02:00
build resolves enabled service after project has been loaded
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
0e0ed91a39
commit
7cf7c6414f
@ -145,6 +145,7 @@ func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runBuild(ctx context.Context, dockerCli command.Cli, backend api.Service, opts buildOptions, services []string) error {
|
func runBuild(ctx context.Context, dockerCli command.Cli, backend api.Service, opts buildOptions, services []string) error {
|
||||||
|
opts.All = true // do not drop resources as build may involve some dependencies by additional_contexts
|
||||||
project, _, err := opts.ToProject(ctx, dockerCli, nil, cli.WithResolvedPaths(true), cli.WithoutEnvironmentResolution)
|
project, _, err := opts.ToProject(ctx, dockerCli, nil, cli.WithResolvedPaths(true), cli.WithoutEnvironmentResolution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -596,3 +596,15 @@ func TestBuildLongOutputLine(t *testing.T) {
|
|||||||
out = res.Combined()
|
out = res.Combined()
|
||||||
assert.Check(t, strings.Contains(out, "long-line Built"))
|
assert.Check(t, strings.Contains(out, "long-line Built"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildDependentImageWithProfile(t *testing.T) {
|
||||||
|
c := NewParallelCLI(t)
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
c.RunDockerComposeCmd(t, "-f", "fixtures/build-test/profiles/compose.yaml", "down", "--rmi=local")
|
||||||
|
})
|
||||||
|
|
||||||
|
res := c.RunDockerComposeCmd(t, "-f", "fixtures/build-test/profiles/compose.yaml", "build", "secret-build-test")
|
||||||
|
out := res.Combined()
|
||||||
|
assert.Check(t, strings.Contains(out, "secret-build-test Built"))
|
||||||
|
}
|
||||||
|
19
pkg/e2e/fixtures/build-test/profiles/Dockerfile
Normal file
19
pkg/e2e/fixtures/build-test/profiles/Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 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 alpine
|
||||||
|
RUN --mount=type=secret,id=test-secret ls -la /run/secrets/; cp /run/secrets/test-secret /tmp
|
||||||
|
|
||||||
|
CMD ["cat", "/tmp/test-secret"]
|
12
pkg/e2e/fixtures/build-test/profiles/compose.yaml
Normal file
12
pkg/e2e/fixtures/build-test/profiles/compose.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
secrets:
|
||||||
|
test-secret:
|
||||||
|
file: test-secret.txt
|
||||||
|
|
||||||
|
services:
|
||||||
|
secret-build-test:
|
||||||
|
profiles: ["test"]
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
secrets:
|
||||||
|
- test-secret
|
1
pkg/e2e/fixtures/build-test/profiles/test-secret.txt
Normal file
1
pkg/e2e/fixtures/build-test/profiles/test-secret.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
SECRET
|
Loading…
x
Reference in New Issue
Block a user