|
57 | 57 | 'workdir': 'working_dir',
|
58 | 58 | }
|
59 | 59 |
|
| 60 | +DOCKER_VALID_URL_PREFIXES = ( |
| 61 | + 'http://', |
| 62 | + 'https://', |
| 63 | +) |
| 64 | + |
| 65 | +DOCKER_VALID_GIT_PREFIXES = ( |
| 66 | + 'git://', |
| 67 | + 'github.com/', |
| 68 | + 'git@', |
| 69 | +) |
| 70 | + |
60 | 71 |
|
61 | 72 | def load(filename):
|
62 | 73 | working_dir = os.path.dirname(filename)
|
@@ -356,14 +367,25 @@ def resolve_host_path(volume, working_dir):
|
356 | 367 | def resolve_build_path(build_path, working_dir=None):
|
357 | 368 | if working_dir is None:
|
358 | 369 | raise Exception("No working_dir passed to resolve_build_path")
|
359 |
| - return expand_path(working_dir, build_path) |
| 370 | + if is_git_url(build_path) or is_url(build_path): |
| 371 | + return build_path |
| 372 | + else: |
| 373 | + return expand_path(working_dir, build_path) |
360 | 374 |
|
361 | 375 |
|
362 | 376 | def validate_paths(service_dict):
|
363 | 377 | if 'build' in service_dict:
|
364 | 378 | build_path = service_dict['build']
|
365 |
| - if not os.path.exists(build_path) or not os.access(build_path, os.R_OK): |
366 |
| - raise ConfigurationError("build path %s either does not exist or is not accessible." % build_path) |
| 379 | + if (not os.path.exists(build_path) or not os.access(build_path, os.R_OK)) and not is_git_url(build_path): |
| 380 | + raise ConfigurationError("build path %s either does not exist, is not accessible or is not a valid url." % build_path) |
| 381 | + |
| 382 | + |
| 383 | +def is_url(build_path): |
| 384 | + return build_path.startswith(DOCKER_VALID_URL_PREFIXES) |
| 385 | + |
| 386 | + |
| 387 | +def is_git_url(build_path): |
| 388 | + return build_path.startswith(DOCKER_VALID_GIT_PREFIXES) or is_url(build_path) and build_path.endswith('.git') |
367 | 389 |
|
368 | 390 |
|
369 | 391 | def merge_volumes(base, override):
|
|
0 commit comments