Add docker-compose defaults
This commit is contained in:
parent
30ac033863
commit
689d377683
12
main.py
12
main.py
@ -66,10 +66,13 @@ def write_build_unit(args, yaml_dict: dict, service_name: str):
|
||||
|
||||
|
||||
def write_network_units(args, yaml_dict):
|
||||
for network_name in yaml_dict.get("networks", []):
|
||||
networks = yaml_dict.get("networks", {})
|
||||
if "default" not in networks:
|
||||
networks["default"] = None
|
||||
for network_name in networks:
|
||||
out_file = args.output_dir / f"{network_name}.network"
|
||||
print(f'Generating network "{network_name}" ({out_file})')
|
||||
network = yaml_dict["networks"].get(network_name)
|
||||
network = networks.get(network_name)
|
||||
if network is None:
|
||||
network = {}
|
||||
|
||||
@ -148,6 +151,11 @@ def write_service_units(args, yaml_dict):
|
||||
if "volumes" in service:
|
||||
enforce_list("volumes", service)
|
||||
unit_file["Container"]["Volume"] = service["volumes"]
|
||||
if "networks" in service:
|
||||
enforce_list("networks", service)
|
||||
unit_file["Container"]["Network"] = service["networks"]
|
||||
else:
|
||||
unit_file["Container"]["Network"] = ["default"]
|
||||
if "devices" in service:
|
||||
unit_file["Container"]["AddDevice"] = service["devices"]
|
||||
if "userns_mode" in service:
|
||||
|
Loading…
Reference in New Issue
Block a user