Fixes #636: env-file shall be resolved relative to the CWD

Signed-off-by: BugFest <bugfest.dev@pm.me>
This commit is contained in:
BugFest 2023-04-07 22:03:28 +02:00 committed by Muayyad Alsadi
parent 620f5d7473
commit 59a59c1a3a
4 changed files with 25 additions and 4 deletions

View File

@ -1526,11 +1526,13 @@ class PodmanCompose:
dirname = os.path.realpath(os.path.dirname(filename))
dir_basename = os.path.basename(dirname)
self.dirname = dirname
# TODO: remove next line
os.chdir(dirname)
dotenv_path = os.path.join(dirname, args.env_file)
dotenv_dict = dotenv_to_dict(dotenv_path)
# env-file is relative to the CWD
dotenv_dict = {}
if args.env_file:
dotenv_path = os.path.realpath(args.env_file)
dotenv_dict = dotenv_to_dict(dotenv_path)
os.environ.update(
{
key: value

View File

@ -0,0 +1,9 @@
running the following commands should always give podman-rocks-123
```
podman-compose -f project/container-compose.yaml --env-file env-files/project-1.env up
```
```
podman-compose -f $(pwd)/project/container-compose.yaml --env-file $(pwd)/env-files/project-1.env up
```

View File

@ -0,0 +1 @@
ZZVAR1=podman-rocks-123

View File

@ -0,0 +1,9 @@
services:
app:
image: busybox
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
tmpfs:
- /run
- /tmp
environment:
ZZVAR1: $ZZVAR1