mirror of
https://github.com/docker/compose.git
synced 2025-07-03 20:04:25 +02:00
Ignore build context path validation when it is not necessary
Signed-off-by: Vitor Anjos <vitorbartier@hotmail.com>
This commit is contained in:
parent
b23eb2deab
commit
17b41b27a8
@ -729,8 +729,21 @@ def validate_extended_service_dict(service_dict, filename, service):
|
|||||||
|
|
||||||
|
|
||||||
def validate_service(service_config, service_names, config_file):
|
def validate_service(service_config, service_names, config_file):
|
||||||
|
def build_image():
|
||||||
|
args = sys.argv[1:]
|
||||||
|
if 'pull' in args:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if '--no-build' in args:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
service_dict, service_name = service_config.config, service_config.name
|
service_dict, service_name = service_config.config, service_config.name
|
||||||
validate_service_constraints(service_dict, service_name, config_file)
|
validate_service_constraints(service_dict, service_name, config_file)
|
||||||
|
|
||||||
|
if build_image():
|
||||||
|
# We only care about valid paths when actually building images
|
||||||
validate_paths(service_dict)
|
validate_paths(service_dict)
|
||||||
|
|
||||||
validate_cpu(service_config)
|
validate_cpu(service_config)
|
||||||
|
@ -748,6 +748,20 @@ services:
|
|||||||
assert BUILD_CACHE_TEXT not in result.stdout
|
assert BUILD_CACHE_TEXT not in result.stdout
|
||||||
assert BUILD_PULL_TEXT not in result.stdout
|
assert BUILD_PULL_TEXT not in result.stdout
|
||||||
|
|
||||||
|
def test_up_ignore_missing_build_directory(self):
|
||||||
|
self.base_dir = 'tests/fixtures/no-build'
|
||||||
|
result = self.dispatch(['up', '--no-build'])
|
||||||
|
|
||||||
|
assert 'alpine exited with code 0' in result.stdout
|
||||||
|
self.base_dir = None
|
||||||
|
|
||||||
|
def test_pull_ignore_missing_build_directory(self):
|
||||||
|
self.base_dir = 'tests/fixtures/no-build'
|
||||||
|
result = self.dispatch(['pull'])
|
||||||
|
|
||||||
|
assert 'Pulling my-alpine' in result.stderr
|
||||||
|
self.base_dir = None
|
||||||
|
|
||||||
def test_build_pull(self):
|
def test_build_pull(self):
|
||||||
# Make sure we have the latest busybox already
|
# Make sure we have the latest busybox already
|
||||||
pull_busybox(self.client)
|
pull_busybox(self.client)
|
||||||
|
8
tests/fixtures/no-build/docker-compose.yml
vendored
Normal file
8
tests/fixtures/no-build/docker-compose.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
my-alpine:
|
||||||
|
image: alpine:3.12
|
||||||
|
container_name: alpine
|
||||||
|
entrypoint: 'echo It works!'
|
||||||
|
build:
|
||||||
|
context: /this/path/doesnt/exists # and we don't really care. We just want to run containers already pulled.
|
Loading…
x
Reference in New Issue
Block a user