mirror of
https://github.com/containers/podman-compose.git
synced 2024-12-24 15:49:03 +01:00
Fixes #636: env-file shall be resolved relative to the CWD
Signed-off-by: BugFest <bugfest.dev@pm.me>
This commit is contained in:
parent
620f5d7473
commit
59a59c1a3a
@ -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
|
||||
|
9
tests/env-file-tests/README.md
Normal file
9
tests/env-file-tests/README.md
Normal 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
|
||||
```
|
1
tests/env-file-tests/env-files/project-1.env
Normal file
1
tests/env-file-tests/env-files/project-1.env
Normal file
@ -0,0 +1 @@
|
||||
ZZVAR1=podman-rocks-123
|
9
tests/env-file-tests/project/container-compose.yaml
Normal file
9
tests/env-file-tests/project/container-compose.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
environment:
|
||||
ZZVAR1: $ZZVAR1
|
Loading…
Reference in New Issue
Block a user