mirror of
https://github.com/containers/podman-compose.git
synced 2025-05-12 10:14:45 +02:00
Fixing subdirectory from extends where extended service will build a Service from Dockerfile in an own subdirectory
Signed-off-by: kjunker <junker.kurt@googlemail.com>
This commit is contained in:
parent
5c3ec5f49a
commit
56b88639ad
@ -934,7 +934,15 @@ class Podman:
|
|||||||
volumes = output.splitlines()
|
volumes = output.splitlines()
|
||||||
return volumes
|
return volumes
|
||||||
|
|
||||||
def normalize_service(service):
|
def normalize_service(service, sub_dir=''):
|
||||||
|
if sub_dir and 'build' in service and 'context' in service['build']:
|
||||||
|
context = service['build']['context']
|
||||||
|
if re.match('^(((\./)?(\w+)+(/\w+)+?$)|(\.$))', context):
|
||||||
|
if context.startswith('.'):
|
||||||
|
context = context.replace('.', sub_dir)
|
||||||
|
else:
|
||||||
|
context = sub_dir + os.sep + 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]]
|
||||||
@ -1014,9 +1022,12 @@ def resolve_extends(services, service_names, environ):
|
|||||||
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]
|
||||||
|
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)
|
normalize_service(from_service, subdirectory)
|
||||||
else:
|
else:
|
||||||
from_service = services.get(from_service_name, {}).copy()
|
from_service = services.get(from_service_name, {}).copy()
|
||||||
del from_service["_deps"]
|
del from_service["_deps"]
|
||||||
|
Loading…
Reference in New Issue
Block a user