From c35258d44d61450b473c1cc2fa0aae98b254d0fc Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Wed, 26 Nov 2025 18:59:38 -0800 Subject: [PATCH] fixed syntax for portainer --- _build/portainer_template_build.py | 23 ++++++----- templates.json | 62 +++++++++++++++--------------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/_build/portainer_template_build.py b/_build/portainer_template_build.py index 87ecb38..54bb345 100644 --- a/_build/portainer_template_build.py +++ b/_build/portainer_template_build.py @@ -126,17 +126,15 @@ def parse_ports(compose_path: Path): return ports_list - - # --------------------------------------------------------- # Parse volumes from docker-compose.yml -# Returns a list of dicts: {"container": container_path} +# Returns a list of dicts: {"container": "/container/path"} # --------------------------------------------------------- def parse_volumes(compose_path: Path): if not compose_path.exists(): return [] - volumes_list = [] + volumes = [] lines = compose_path.read_text().splitlines() in_volumes = False @@ -147,13 +145,18 @@ def parse_volumes(compose_path: Path): continue if in_volumes: if not stripped or not stripped.startswith("-"): - break - vol_str = stripped[1:].strip() - parts = vol_str.split(":", 1) - container_path = parts[1] if len(parts) == 2 else parts[0] - volumes_list.append({"container": container_path}) + break # end of volumes section + # remove "- " prefix + volume_str = stripped[1:].strip() + # split by ':' to separate host path from container path + parts = volume_str.split(":", 1) + container_path = parts[-1].strip() # take container path only + # remove quotes and inline comments + container_path = container_path.split("#")[0].strip().strip('"').strip("'") + if container_path: + volumes.append({"container": container_path}) - return volumes_list + return volumes # --------------------------------------------------------- # Parse environment variables from sample.env or env-sample diff --git a/templates.json b/templates.json index 366bce1..4cb683d 100644 --- a/templates.json +++ b/templates.json @@ -52,10 +52,10 @@ "ports": [], "volumes": [ { - "container": "-./data}/website:/data\"" + "container": "-./data}/website:/data" }, { - "container": "/usr/local/etc/php/php.ini\"" + "container": "/usr/local/etc/php/php.ini" } ] }, @@ -160,7 +160,7 @@ "ports": [], "volumes": [ { - "container": "-/tmp}/wallabag:/var/www/wallabag/web/assets/images\"" + "container": "-/tmp}/wallabag:/var/www/wallabag/web/assets/images" } ] }, @@ -216,10 +216,10 @@ ], "volumes": [ { - "container": "-./data}/thunderbird/config:/config:rw\"" + "container": "-./data}/thunderbird/config:/config:rw" }, { - "container": "-./data}/thunderbird/export:/export:rw\"" + "container": "-./data}/thunderbird/export:/export:rw" } ] }, @@ -435,10 +435,10 @@ ], "volumes": [ { - "container": "/data # Stores raw videos" + "container": "/data" }, { - "container": "/config # Custom configs" + "container": "/config" } ] }, @@ -518,10 +518,10 @@ "ports": [], "volumes": [ { - "container": "/etc/timezone:ro\"" + "container": "/etc/timezone:ro" }, { - "container": "/etc/localtime:ro\"" + "container": "/etc/localtime:ro" } ] }, @@ -603,10 +603,10 @@ ], "volumes": [ { - "container": "/etc/pihole'" + "container": "/etc/pihole" }, { - "container": "/etc/dnsmasq.d'" + "container": "/etc/dnsmasq.d" } ] }, @@ -775,7 +775,7 @@ "ports": [], "volumes": [ { - "container": "-./data}/nc_data:/usr/app/data\"" + "container": "-./data}/nc_data:/usr/app/data" } ] }, @@ -1333,16 +1333,16 @@ ], "volumes": [ { - "container": "-./data}/qbit/config:/config\"" + "container": "-./data}/qbit/config:/config" }, { - "container": "-./data}/qbit/downloads:/downloads\"" + "container": "-./data}/qbit/downloads:/downloads" }, { - "container": "-./data}/qbit/incomplete:/incomplete\"" + "container": "-./data}/qbit/incomplete:/incomplete" }, { - "container": "/dev/net/tun'" + "container": "/dev/net/tun" } ] }, @@ -1486,10 +1486,10 @@ "container": "/var/lib/mysql" }, { - "container": "/etc/timezone:ro\"" + "container": "/etc/timezone:ro" }, { - "container": "/etc/localtime:ro\"" + "container": "/etc/localtime:ro" } ] }, @@ -1590,7 +1590,7 @@ "container": "-./data}/codeserver:/data" }, { - "container": "-./data}/codeserver-config:/config\"" + "container": "-./data}/codeserver-config:/config" } ] }, @@ -1720,22 +1720,22 @@ ], "volumes": [ { - "container": "-./data}/handbrake/ghb-config:/config\"" + "container": "-./data}/handbrake/ghb-config:/config" }, { - "container": "-./data}/handbrake/storage:/storage\"" + "container": "-./data}/handbrake/storage:/storage" }, { - "container": "-./data}/handbrake/complete:/output\"" + "container": "-./data}/handbrake/complete:/output" }, { - "container": "-./data}/handbrake/watch:/watch\"" + "container": "-./data}/handbrake/watch:/watch" }, { - "container": "-./data}/handbrake/watch2:/watch2\"" + "container": "-./data}/handbrake/watch2:/watch2" }, { - "container": "-./data}/handbrake/trash:/trash\"" + "container": "-./data}/handbrake/trash:/trash" } ] }, @@ -2061,10 +2061,10 @@ "ports": [], "volumes": [ { - "container": "-./config}/homepage:/app/config # Make sure your local config directory exists" + "container": "-./config}/homepage:/app/config" }, { - "container": "/var/run/docker.sock # (optional) For docker integrations" + "container": "/var/run/docker.sock" } ] }, @@ -2490,7 +2490,7 @@ "ports": [], "volumes": [ { - "container": "-./data}/vault-data:/data\"" + "container": "-./data}/vault-data:/data" } ] }, @@ -2633,10 +2633,10 @@ ], "volumes": [ { - "container": "-./data}/proxy/data:/data\"" + "container": "-./data}/proxy/data:/data" }, { - "container": "-./data}/proxy/letsencrypt:/etc/letsencrypt\"" + "container": "-./data}/proxy/letsencrypt:/etc/letsencrypt" } ] }, @@ -3412,7 +3412,7 @@ ], "volumes": [ { - "container": "-./data/prowlarr/config}:/config\"" + "container": "-./data/prowlarr/config}:/config" } ] },