Uh oh!
There was an error while loading. Please reload this page.
feat(core): Add support for working with env files - #684
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #684 +/- ##
=======================================
Coverage ? 85.58% =======================================
Files ? 12 Lines ? 666 Branches ? 104 =======================================
Hits ? 570 Misses ? 74 Partials ? 22 ☔ View full report in Codecov by Sentry. |
sasa-buklijas
commented
Aug 16, 2024
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=TrueBIKE_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=developmentWe 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) |
sasa-buklijas
commented
Aug 16, 2024
@Tranquility2 OK, thanks for explanation. Is there some way, one line, to get container internal IP address ? Only solution that I have found is: |
Tranquility2
commented
Aug 16, 2024
I assume you mean fromtestcontainers.redisimportRedisContainerwithRedisContainer() asredis:
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) |
Tranquility2
commented
Aug 16, 2024
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. |
sasa-buklijas
commented
Aug 17, 2024
@Tranquility2 thanks P.S. |
alexanderankin
commented
Aug 17, 2024
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. |
Tranquility2
commented
Aug 17, 2024
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 |
Uh oh!
There was an error while loading. Please reload this page.
Tranquility2
commented
Nov 11, 2024
@alexanderankin is this not also intend to be merged? |
Tranquility2
commented
Nov 16, 2024
Moved to #737 to clean the irrelevant discussion :) |
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> ...