testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

Feature: Support static env config from file

Open Tranquility2 opened this issue 1 year ago • 2 comments

What are you trying to do?

Add missing implementation of docker run --env-file <file> ...

Why should it be done this way?

Users should not be required to load each env var manually if they have an env file. (this is the common case for quite a few services)

For example, if I would have an Redis service with some config:

# 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 with_env 7 times + keeping a single source of truth for the env config.

Other references:

Docker official Docs

Tranquility2 avatar Aug 17 '24 20:08 Tranquility2

@Tranquility2 wanna work on this together?

biniyam69 avatar Aug 31 '24 17:08 biniyam69

@biniyam69 checkout https://github.com/testcontainers/testcontainers-python/pull/684 if you have any comment/ideas/remarks I'll be happy to update.

Tranquility2 avatar Sep 01 '24 08:09 Tranquility2