forked from extern/podman-compose
FIXES #371: respect COMPOSE_FILE env
This commit is contained in:
parent
d8dba61e08
commit
d1d0f9e452
@ -1016,6 +1016,23 @@ def dotenv_to_dict(dotenv_path):
|
|||||||
return {}
|
return {}
|
||||||
return dotenv_values(dotenv_path)
|
return dotenv_values(dotenv_path)
|
||||||
|
|
||||||
|
COMPOSE_DEFAULT_LS = [
|
||||||
|
"compose.yaml",
|
||||||
|
"compose.yml",
|
||||||
|
"compose.override.yaml",
|
||||||
|
"compose.override.yml",
|
||||||
|
"podman-compose.yaml",
|
||||||
|
"podman-compose.yml",
|
||||||
|
"docker-compose.yml",
|
||||||
|
"docker-compose.yaml",
|
||||||
|
"docker-compose.override.yml",
|
||||||
|
"docker-compose.override.yaml",
|
||||||
|
"container-compose.yml",
|
||||||
|
"container-compose.yaml",
|
||||||
|
"container-compose.override.yml",
|
||||||
|
"container-compose.override.yaml",
|
||||||
|
]
|
||||||
|
|
||||||
class PodmanCompose:
|
class PodmanCompose:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.podman_version = None
|
self.podman_version = None
|
||||||
@ -1074,23 +1091,14 @@ class PodmanCompose:
|
|||||||
def _parse_compose_file(self):
|
def _parse_compose_file(self):
|
||||||
args = self.global_args
|
args = self.global_args
|
||||||
cmd = args.command
|
cmd = args.command
|
||||||
|
pathsep = os.environ.get("COMPOSE_PATH_SEPARATOR", None) or os.pathsep
|
||||||
if not args.file:
|
if not args.file:
|
||||||
args.file = list(filter(os.path.exists, [
|
default_str = os.environ.get("COMPOSE_FILE", None)
|
||||||
"compose.yaml",
|
if default_str:
|
||||||
"compose.yml",
|
default_ls = default_str.split(pathsep)
|
||||||
"compose.override.yaml",
|
else:
|
||||||
"compose.override.yml",
|
default_ls = COMPOSE_DEFAULT_LS
|
||||||
"podman-compose.yaml",
|
args.file = list(filter(os.path.exists, default_ls))
|
||||||
"podman-compose.yml",
|
|
||||||
"docker-compose.yml",
|
|
||||||
"docker-compose.yaml",
|
|
||||||
"docker-compose.override.yml",
|
|
||||||
"docker-compose.override.yaml",
|
|
||||||
"container-compose.yml",
|
|
||||||
"container-compose.yaml",
|
|
||||||
"container-compose.override.yml",
|
|
||||||
"container-compose.override.yaml"
|
|
||||||
]))
|
|
||||||
files = args.file
|
files = args.file
|
||||||
if not files:
|
if not files:
|
||||||
print("no compose.yaml, docker-compose.yml or container-compose.yml file found, pass files with -f")
|
print("no compose.yaml, docker-compose.yml or container-compose.yml file found, pass files with -f")
|
||||||
@ -1128,13 +1136,12 @@ class PodmanCompose:
|
|||||||
dotenv_path = os.path.join(dirname, ".env")
|
dotenv_path = os.path.join(dirname, ".env")
|
||||||
self.environ = dict(os.environ)
|
self.environ = dict(os.environ)
|
||||||
self.environ.update(dotenv_to_dict(dotenv_path))
|
self.environ.update(dotenv_to_dict(dotenv_path))
|
||||||
# TODO: should read and respect those env variables
|
|
||||||
# see: https://docs.docker.com/compose/reference/envvars/
|
# see: https://docs.docker.com/compose/reference/envvars/
|
||||||
# see: https://docs.docker.com/compose/env-file/
|
# see: https://docs.docker.com/compose/env-file/
|
||||||
self.environ.update({
|
self.environ.update({
|
||||||
"COMPOSE_FILE": os.path.basename(filename),
|
"COMPOSE_FILE": os.path.basename(filename),
|
||||||
"COMPOSE_PROJECT_NAME": self.project_name,
|
"COMPOSE_PROJECT_NAME": self.project_name,
|
||||||
"COMPOSE_PATH_SEPARATOR": ":",
|
"COMPOSE_PATH_SEPARATOR": pathsep,
|
||||||
})
|
})
|
||||||
compose = {'_dirname': dirname}
|
compose = {'_dirname': dirname}
|
||||||
for filename in files:
|
for filename in files:
|
||||||
|
Loading…
Reference in New Issue
Block a user