micahhausler / container-transform

Transforms docker-compose, ECS, and Marathon configurations
MIT License
1.41k stars 148 forks source link

Support .env file for docker compose #95

Open TJM opened 5 years ago

TJM commented 5 years ago

Similar to #44 I think, but maybe the situation is different 2 years later?

I am trying to convert https://github.com/jfrog/artifactory-docker-examples/tree/master/docker-compose/xray

$ container-transform -i compose -o marathon xray.yml
Traceback (most recent call last):
(SNIP)
ValueError: invalid literal for int() with base 10: '$XRAY_SERVER_PORT'

Apparently they are using the ".env" file as per https://docs.docker.com/compose/environment-variables/#the-env-file

It seems like container-transform would need to parse the compose file the same way docker compose does to produce the same results?

I tried appending the variables to the "docker-compose.yaml" (xray.yml) file, but the results were not positive either.

$ echo '' >> xray.yml # add a newline to the end of the file
$ sed -e 's/=/: /' .env >> xray.yml

... same error :(

~tommy

Dzhuneyt commented 5 years ago

This is definitely needed. I tried using docker-compose config | container-transform -v which in theory should output the YML file with dynamic values retrieved from the .env file and pass them to container-transform, but I get the same error:

    'container_port': int(parts[1]),
ValueError: invalid literal for int() with base 10: '80/tc'
Dzhuneyt commented 5 years ago

Actually, now I just noticed that the issue (error) was caused when I declare the ports using: - 8888:80/tcp instead of - 8888:80. Still a thing to be fixed in my opinion.