question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0.3.11 breaking `j2` usage of ENV vars in `docker-compose up`

See original GitHub issue

Our docker-compose up and ecs-cli up (AWS Elastic Container Service (ECS)) deploys just started failing all of the sudden with:

appserver_1 | Traceback (most recent call last):
appserver_1 | File “/usr/local/bin/j2”, line 11, in <module>
appserver_1 | sys.exit(main())
appserver_1 | File “/usr/local/lib/python2.7/dist-packages/j2cli/cli.py”, line 206, in main
appserver_1 | sys.argv[1:]
appserver_1 | File “/usr/local/lib/python2.7/dist-packages/j2cli/cli.py”, line 186, in render_command
appserver_1 | result = renderer.render(args.template, context)
appserver_1 | File “/usr/local/lib/python2.7/dist-packages/j2cli/cli.py”, line 87, in render
appserver_1 | .render(context) \
appserver_1 | File “/usr/local/lib/python2.7/dist-packages/jinja2/environment.py”, line 1008, in render
appserver_1 | return self.environment.handle_exception(exc_info, True)
appserver_1 | File “/usr/local/lib/python2.7/dist-packages/jinja2/environment.py”, line 780, in handle_exception appserver_1 | reraise(exc_type, exc_value, tb)
appserver_1 | File “/templates/ssmtp.tpl”, line 8, in top-level template code
appserver_1 | rewriteDomain={{ SMTP_FROM_HOSTNAME }}
appserver_1 | jinja2.exceptions.UndefinedError: ‘SMTP_RELAY_HOST’ is undefined

These are containers that have an entrypoint script that uses j2 to copy a template file into a regular file.

j2 /templates/ssmtp.tpl > /etc/ssmtp/ssmtp.conf

I pinned the version back to 0.3.10 with pip install -Iv j2cli==0.3.10 in the Dockerfile and things are working again.

I recommend reverting https://github.com/kolypto/j2cli/pull/42 (today’s release) and pushing this out immediately until a correct patch/PR can be created as it is most likely breaking other builds and deployments. It took me a few hours to arrive here and others may be struggling with why this is happening to them as well.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kolyptocommented, Jul 19, 2019

Wow, that’s unexpected. Sorry. I’ve pulled the breaking release from pip; will investigate and find out the root cause. Thank you for reporting!

1reaction
ElijahLynncommented, Jul 20, 2019

I’ve made a new release which both has the new functionality, and is backwards-compatible. Please tell me if j2cli==0.3.12b0 works for you? @ElijahLynn @cmeisinger @raymondbutcher

Just had a look here https://github.com/kolypto/j2cli/commit/26a67e9419d96b7f92871e8b93dba00306c5df0b and that is quite the addition now! Thanks, I’ll see if I can test it soon, as I do need to revert the pin anyways. It may be Monday for my schedule. Thanks again

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables in Compose | Docker Documentation
When you run docker-compose up with this configuration, Compose looks for the POSTGRES_VERSION environment variable in the shell and substitutes its value ...
Read more >
Docker compose env variable not substituted - Stack Overflow
env file but the variable is set to '' by docker-compose in the environment variable 'DB_HOST' and is showing as jdbc://mysql://:app_db . But...
Read more >
Environment variables in Compose | Docker Documentation
When you set the same environment variable in multiple files, here's the priority used by Compose to choose which value to use: Compose...
Read more >
Docker Compose can't get environment variables and relation ...
It's because you're setting the environment variables at the docker-compose.yml but trying to reference them in build time (aka RUN env ).
Read more >
Custom configuration - Testcontainers for Java
Note that when using environment variables, configuration property names should be ... Used by Ryuk, Docker Compose, and a few other containers that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found