-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ports_refactor
- Loading branch information
Showing
15 changed files
with
172 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "4.8.2" | ||
".": "4.9.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
services: | ||
runs-always: &simple-service | ||
image: alpine:latest | ||
init: true | ||
command: | ||
- sh | ||
- -c | ||
- 'while true; do sleep 0.1 ; date -Ins; done' | ||
runs-profile-a: | ||
<<: *simple-service | ||
profiles: | ||
- profile-a | ||
runs-profile-b: | ||
<<: *simple-service | ||
profiles: | ||
- profile-b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from testcontainers.core.container import DockerContainer | ||
|
||
|
||
|
@@ -17,3 +20,29 @@ def test_get_logs(): | |
assert isinstance(stdout, bytes) | ||
assert isinstance(stderr, bytes) | ||
assert "Hello from Docker".encode() in stdout, "There should be something on stdout" | ||
|
||
|
||
def test_docker_container_with_env_file(): | ||
"""Test that environment variables can be loaded from a file""" | ||
with tempfile.TemporaryDirectory() as temp_directory: | ||
env_file_path = Path(temp_directory) / "env_file" | ||
with open(env_file_path, "w") as f: | ||
f.write( | ||
""" | ||
TEST_ENV_VAR=hello | ||
NUMBER=123 | ||
DOMAIN=example.org | ||
ADMIN_EMAIL=admin@${DOMAIN} | ||
ROOT_URL=${DOMAIN}/app | ||
""" | ||
) | ||
container = DockerContainer("alpine").with_command("tail -f /dev/null") # Keep the container running | ||
container.with_env_file(env_file_path) # Load the environment variables from the file | ||
with container: | ||
output = container.exec("env").output.decode("utf-8").strip() | ||
assert "TEST_ENV_VAR=hello" in output | ||
assert "NUMBER=123" in output | ||
assert "DOMAIN=example.org" in output | ||
assert "[email protected]" in output | ||
assert "ROOT_URL=example.org/app" in output | ||
print(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.