My environement variables doesnt work with Travis?

here’s my travis.yml

language: python
  - "3.6"

  - docker

  - touch .env
  - pip install docker-compose

  - docker-compose run web sh -c "python test"

When I push on GitHub, everything seem to work Travis side until the test start and Travis come to this line of code in my app :

ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")

When and where do you run?

export DJANGO_ALLOWED_HOSTS = localhost

Also how can you even call?

docker-compose run etc. 

That makes absolutely no sense.

You should consider that in order for your environment variables to be available to your docker-compose.yml file they need to be called from the same terminal where you exported DJANGO_ALLOWED_HOSTS.

You need to source your env file before you call:

docker-compose up -d

Once you’ve done that, run the following:

set -a
source .my-env
docker-compose up -d

If you’re still getting an error, I suggest you use tox and post back.