[REF] refactor docker 'volumes' arg
This commit is contained in:
parent
a0eb99fd48
commit
5a4f777fd4
|
|
@ -27,7 +27,7 @@ def run_container(
|
||||||
container_name,
|
container_name,
|
||||||
command=None,
|
command=None,
|
||||||
ports=False,
|
ports=False,
|
||||||
volumes=False,
|
volumes={},
|
||||||
environments={},
|
environments={},
|
||||||
links={},
|
links={},
|
||||||
detach=False,
|
detach=False,
|
||||||
|
|
@ -44,20 +44,14 @@ def run_container(
|
||||||
internal_port=internal_port, host_port=host_port
|
internal_port=internal_port, host_port=host_port
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if volumes:
|
for k, v in volumes.items():
|
||||||
for volume in volumes:
|
debug_docker_command += " --volume {k}:{v}\\\n".format(
|
||||||
external_path, internal_path = volume.split(":")
|
k=str(k), v=str(v)
|
||||||
debug_docker_command += (
|
)
|
||||||
" --volume {external_path}:{internal_path}\\\n".format(
|
for k, v in environments.items():
|
||||||
external_path=external_path, internal_path=internal_path
|
debug_docker_command += " --env {k}={v}\\\n".format(k=k, v=v)
|
||||||
)
|
for k, v in links.items():
|
||||||
)
|
debug_docker_command += " --link {k}:{v}\\\n".format(k=k, v=v)
|
||||||
if links:
|
|
||||||
for k, v in links.items():
|
|
||||||
debug_docker_command += " --link {k}:{v}\\\n".format(k=k, v=v)
|
|
||||||
if environments:
|
|
||||||
for k, v in environments.items():
|
|
||||||
debug_docker_command += " --env {k}={v}\\\n".format(k=k, v=v)
|
|
||||||
if auto_remove:
|
if auto_remove:
|
||||||
debug_docker_command += " --rm"
|
debug_docker_command += " --rm"
|
||||||
if detach:
|
if detach:
|
||||||
|
|
@ -72,13 +66,8 @@ def run_container(
|
||||||
name=container_name,
|
name=container_name,
|
||||||
command=command,
|
command=command,
|
||||||
ports=ports,
|
ports=ports,
|
||||||
volumes=volumes,
|
volumes=[str(k) + ":" + str(v) for k, v in volumes.items()],
|
||||||
environment=environments,
|
environment=environments,
|
||||||
# environment=[
|
|
||||||
# "POSTGRES_USER=odoo",
|
|
||||||
# "POSTGRES_PASSWORD=odoo",
|
|
||||||
# "POSTGRES_DB=postgres",
|
|
||||||
# ],
|
|
||||||
links=links,
|
links=links,
|
||||||
detach=detach,
|
detach=detach,
|
||||||
auto_remove=auto_remove,
|
auto_remove=auto_remove,
|
||||||
|
|
|
||||||
|
|
@ -186,10 +186,10 @@ def run_odoo(
|
||||||
and alternative_xml_rpc_port
|
and alternative_xml_rpc_port
|
||||||
or ctx.obj["config"]["odoo_host_xmlrpc_port"],
|
or ctx.obj["config"]["odoo_host_xmlrpc_port"],
|
||||||
},
|
},
|
||||||
volumes=[
|
volumes={
|
||||||
"%s:/env/" % (env_path),
|
env_path: "/env/",
|
||||||
"%s:/odoo_env/" % (odoo_env_path),
|
odoo_env_path: "/odoo_env/",
|
||||||
],
|
},
|
||||||
links={ctx.obj["config"]["postgres_container_name"]: "db"},
|
links={ctx.obj["config"]["postgres_container_name"]: "db"},
|
||||||
detach=detached_container,
|
detach=detached_container,
|
||||||
auto_remove=True,
|
auto_remove=True,
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,12 @@ def get_postgres_container(ctx):
|
||||||
"POSTGRES_DB": "postgres",
|
"POSTGRES_DB": "postgres",
|
||||||
"PGDATA": "/var/lib/postgresql/data/pgdata",
|
"PGDATA": "/var/lib/postgresql/data/pgdata",
|
||||||
},
|
},
|
||||||
volumes=[
|
volumes={
|
||||||
"%s:/env/" % ctx.obj["env_folder_path"],
|
ctx.obj["env_folder_path"]: "/env/",
|
||||||
"%s:/var/lib/postgresql/data/pgdata/"
|
ctx.obj[
|
||||||
% ctx.obj["postgres_folder_path"],
|
"postgres_folder_path"
|
||||||
],
|
]: "/var/lib/postgresql/data/pgdata/",
|
||||||
|
},
|
||||||
detach=True,
|
detach=True,
|
||||||
)
|
)
|
||||||
# TODO, improve me.
|
# TODO, improve me.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user