forked from extern/podman-compose
#130: handle nested extend and normalize build context
This commit is contained in:
parent
0bde01de07
commit
132a22b524
@ -935,14 +935,22 @@ class Podman:
|
|||||||
return volumes
|
return volumes
|
||||||
|
|
||||||
def normalize_service(service, sub_dir=''):
|
def normalize_service(service, sub_dir=''):
|
||||||
if sub_dir and 'build' in service and 'context' in service['build']:
|
if sub_dir and 'build' in service:
|
||||||
context = service['build']['context']
|
build = service['build']
|
||||||
if re.match('^(((\./)?(\w+)+(/\w+)+?$)|(\.$))', context):
|
context = build if is_str(build) else build.get('context', None)
|
||||||
if context.startswith('.'):
|
context = context or ''
|
||||||
context = context.replace('.', sub_dir)
|
if context or sub_dir:
|
||||||
|
if context.startswith('./'):
|
||||||
|
context = context[2:]
|
||||||
|
if sub_dir:
|
||||||
|
context = os.path.join(sub_dir, context)
|
||||||
|
context = context.rstrip('/')
|
||||||
|
if not context:
|
||||||
|
context = '.'
|
||||||
|
if is_str(build):
|
||||||
|
service['build'] = context
|
||||||
else:
|
else:
|
||||||
context = sub_dir + os.sep + context
|
service['build']['context'] = context
|
||||||
service['build']['context'] = context
|
|
||||||
for key in ("env_file", "security_opt", "volumes"):
|
for key in ("env_file", "security_opt", "volumes"):
|
||||||
if key not in service: continue
|
if key not in service: continue
|
||||||
if is_str(service[key]): service[key]=[service[key]]
|
if is_str(service[key]): service[key]=[service[key]]
|
||||||
@ -1018,13 +1026,13 @@ def resolve_extends(services, service_names, environ):
|
|||||||
if not from_service_name: continue
|
if not from_service_name: continue
|
||||||
filename = ext.get("file", None)
|
filename = ext.get("file", None)
|
||||||
if filename:
|
if filename:
|
||||||
|
if filename.startswith('./'):
|
||||||
|
filename = filename[2:]
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
content = yaml.safe_load(f) or {}
|
content = yaml.safe_load(f) or {}
|
||||||
if "services" in content:
|
if "services" in content:
|
||||||
content = content["services"]
|
content = content["services"]
|
||||||
subdirectory = filename.rsplit(os.sep, 1)[0]
|
subdirectory = os.path.dirname(filename)
|
||||||
if filename == subdirectory:
|
|
||||||
subdirectory = ''
|
|
||||||
content = rec_subs(content, environ)
|
content = rec_subs(content, environ)
|
||||||
from_service = content.get(from_service_name, {})
|
from_service = content.get(from_service_name, {})
|
||||||
normalize_service(from_service, subdirectory)
|
normalize_service(from_service, subdirectory)
|
||||||
|
@ -1 +1 @@
|
|||||||
FROM bash as base
|
FROM buysbox as base
|
||||||
|
Loading…
Reference in New Issue
Block a user