-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): Add support for working with env files #684
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #684 +/- ##
=======================================
Coverage ? 80.61%
=======================================
Files ? 12
Lines ? 614
Branches ? 91
=======================================
Hits ? 495
Misses ? 92
Partials ? 27 ☔ View full report in Codecov by Sentry. |
It is great, but not sure that it will be useful, to me at least. I start testcontainers-python via pytest and have 3 containers running: redis, postgres and my own FastAPI app. Do to all this I can not use one dot-env file. If I am doing something wrong, please correct me. |
Let me try an sort this out :)
# Redis Bike Commpany Demo Application: Example .env file.
REDIS_URL=redis://localhost:6379/?decode_responses=True
BIKE_INDEX_NAME="idx:bikes"
STORE_INDEX_NAME="idx:stores"
REDIS_KEY_BASE="redisbikeco"
BIKE_KEY_BASE="redisbikeco:bike"
STORE_KEY_BASE="redisbikeco:store"
FLASK_ENV=development We would now be able to load it without evoking TL;DR your current solution is great as its dynamic, we also need to support static config from file (As this is the common case for quite a few services) |
@Tranquility2 OK, thanks for explanation. Is there some way, one line, to get container internal IP address ? Only solution that I have found is:
|
I assume you mean from testcontainers.redis import RedisContainer
with RedisContainer() as redis:
redis_container_ip_address = redis.get_docker_client().bridge_ip(redis._container.id) (This should provide the same data as in the example you found) |
Some more details (if you are interested)Usually
self.get_docker_client().gateway_ip(self._container.id) and self.get_docker_client().bridge_ip(self._container.id) are very useful for some cases.
|
@Tranquility2 thanks P.S. |
im not sure about this use case. the issue linked sets hostnames as variables. shouldn't those be constants in code for easy updating? like youre passing the same hostname in the same function (same module at least) to both set and pass to other containers. im not convinced. |
I see this is confusing, let me open a new issue :) |
@alexanderankin I've updated the related issue to #687 (sorry for the mix up) just to be extra clear this is a docker feature, we are just adding support to do the same as |
Fix: #687
Users should not be required to load each env var manually if they have an env file.
Added support for loading a dot-env file.
Usage:
This is an implementation of
docker run --env-file <file> ...