Skip to content

Commit cf7ddda

Browse files
committed
services: mk host volume with user before docker does with root
1 parent 4d4968f commit cf7ddda

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Diff for: src/backends/compose/compose_backend.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,12 @@ def get_service_container_name(self, service_name: str):
457457
def service_from_json(self, service_name: str) -> object:
458458
obj = services[service_name]
459459
volumes = obj.get("volumes", [])
460-
volumes += [f"{self.config_dir}" + filepath for filepath in obj.get("config_files", [])]
460+
for bind_mount in obj.get("config_files", []):
461+
volume_name, mount_path = bind_mount.split(":")
462+
hostpath = self.config_dir / volume_name
463+
# Create the directory now so it has python-user permissions not docker-root
464+
hostpath.mkdir(parents=True, exist_ok=True)
465+
volumes += [f"{hostpath}:{mount_path}"]
461466

462467
ports = []
463468
if "container_port" and "warnet_port" in obj:

Diff for: src/backends/kubernetes/kubernetes_backend.py

-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ def service_from_json(self, obj):
721721
volumes = []
722722
for vol in obj.get("config_files", []):
723723
volume_name, mount_path = vol.split(":")
724-
volume_name = volume_name.replace("/", "")
725724
volume_mounts.append(client.V1VolumeMount(name=volume_name, mount_path=mount_path))
726725
volumes.append(client.V1Volume(name=volume_name, empty_dir=client.V1EmptyDirVolumeSource()))
727726

Diff for: src/warnet/services.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"container_name_suffix": "fork-observer",
3232
"warnet_port": "23001",
3333
"container_port": "2323",
34-
"config_files": [f"/{FO_CONF_NAME}:/app/config.toml"],
34+
"config_files": [f"{FO_CONF_NAME}:/app/config.toml"],
3535
},
3636
"grafana": {
3737
"backends": ["compose"],
@@ -43,8 +43,8 @@
4343
"grafana-storage:/var/lib/grafana"
4444
],
4545
"config_files": [
46-
f"/{GRAFANA_PROVISIONING}/datasources:/etc/grafana/provisioning/datasources",
47-
f"/{GRAFANA_PROVISIONING}/dashboards:/etc/grafana/provisioning/dashboards",
46+
f"{GRAFANA_PROVISIONING}/datasources:/etc/grafana/provisioning/datasources",
47+
f"{GRAFANA_PROVISIONING}/dashboards:/etc/grafana/provisioning/dashboards",
4848
],
4949
"environment": [
5050
"GF_LOG_LEVEL=debug",
@@ -76,7 +76,7 @@
7676
"container_name_suffix": "prometheus",
7777
"warnet_port": "23004",
7878
"container_port": "9090",
79-
"config_files": [f"/{PROM_CONF_NAME}:/etc/prometheus/prometheus.yml"],
79+
"config_files": [f"{PROM_CONF_NAME}:/etc/prometheus/prometheus.yml"],
8080
"args": ["--config.file=/etc/prometheus/prometheus.yml"]
8181
},
8282
"simln": {
@@ -87,6 +87,6 @@
8787
"LOG_LEVEL=debug",
8888
"SIMFILE_PATH=/simln/sim.json"
8989
],
90-
"config_files": ["/simln:/simln"]
90+
"config_files": ["simln:/simln"]
9191
},
9292
}

0 commit comments

Comments
 (0)