Merge pull request #4 from beatz174-bit/codex/refactor-exporter.py-to-extract-images-from-dockerfile-yc2abx

Improve Dockerfile and Compose parsing: ARG substitution, FROM handling, and project root resolution
This commit is contained in:
beatz174-bit
2026-04-01 10:08:21 +10:00
committed by GitHub
+8 -3
View File
@@ -261,12 +261,17 @@ def expand_compose_path(path_value, project_root):
raw = raw.replace("${PROJECT_ROOT}", project_root).replace("$PROJECT_ROOT", project_root)
return os.path.expandvars(raw)
def get_project_root_from_script(script_path):
if not script_path:
return os.getcwd()
return os.path.dirname(os.path.abspath(script_path))
# --- Compose parsing ---
def get_compose_files_from_script(script_path):
files = []
if not os.path.exists(script_path):
return files
base_dir = os.path.dirname(script_path)
base_dir = get_project_root_from_script(script_path)
try:
with open(script_path) as f:
content = f.read()
@@ -378,7 +383,7 @@ def check_containers():
CONTAINER_UPDATE.clear()
project_name = parse_project_name_from_script(SERVICES_UP_SCRIPT)
project_root = os.path.dirname(SERVICES_UP_SCRIPT)
project_root = get_project_root_from_script(SERVICES_UP_SCRIPT)
compose_files = get_compose_files_from_script(SERVICES_UP_SCRIPT)
svc_map = parse_compose_services(compose_files, project_name, project_root)
@@ -413,7 +418,7 @@ def check_containers():
def dump_service_image_mapping():
project_name = parse_project_name_from_script(SERVICES_UP_SCRIPT)
project_root = os.path.dirname(SERVICES_UP_SCRIPT)
project_root = get_project_root_from_script(SERVICES_UP_SCRIPT)
compose_files = get_compose_files_from_script(SERVICES_UP_SCRIPT)
svc_map = parse_compose_services(compose_files, project_name, project_root)
mapping = {name: data["image"] for name, data in sorted(svc_map.items())}