forked from extern/podman-compose
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))
|
dirname = os.path.realpath(os.path.dirname(filename))
|
||||||
dir_basename = os.path.basename(dirname)
|
dir_basename = os.path.basename(dirname)
|
||||||
self.dirname = dirname
|
self.dirname = dirname
|
||||||
# TODO: remove next line
|
|
||||||
os.chdir(dirname)
|
|
||||||
|
|
||||||
dotenv_path = os.path.join(dirname, args.env_file)
|
# env-file is relative to the CWD
|
||||||
dotenv_dict = dotenv_to_dict(dotenv_path)
|
dotenv_dict = {}
|
||||||
|
if args.env_file:
|
||||||
|
dotenv_path = os.path.realpath(args.env_file)
|
||||||
|
dotenv_dict = dotenv_to_dict(dotenv_path)
|
||||||
|
|
||||||
os.environ.update(
|
os.environ.update(
|
||||||
{
|
{
|
||||||
key: value
|
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