Redash not reading ENV variables on setup (in container)


#1

I start redash in Docker container and push all required variables via Environment variables as I don’t want to store credentials in container.

But it fails to read config from ENV variables:

root@c06cf7519ff6:/opt/redash/current# sudo -u redash bin/run ./manage.py database create_tables
sed: can't read .env: No such file or directory
[2017-08-18 11:09:03,503][PID:62][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2017-08-18 11:09:03,532][PID:62][INFO][root] Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Traceback (most recent call last):
  File "/opt/redash/redash.2.0.0.b2990/manage.py", line 6, in <module>
    from redash.cli import manager
  File "/opt/redash/redash.2.0.0.b2990/redash/__init__.py", line 73, in <module>
    reset_new_version_status()
  File "/opt/redash/redash.2.0.0.b2990/redash/version_check.py", line 34, in reset_new_version_status
    latest_version = get_latest_version()
  File "/opt/redash/redash.2.0.0.b2990/redash/version_check.py", line 40, in get_latest_version
    return redis_connection.get(REDIS_KEY)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 880, in get
    return self.execute_command('GET', name)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 578, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 563, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 538, in send_packed_command
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 442, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
root@c06cf7519ff6:/opt/redash/current# env
REDASH_MAIL_USE_SSL=False
REDASH_MAIL_USERNAME=**********************
HOSTNAME=c06cf7519ff6
REDASH_MAIL_USE_TLS=True
REDASH_REDIS_URL=redis://redis.cluster.com:6005/0
PYTHONUNBUFFERED=0

As you see it tries to connect to localhost instead of redis.cluster.com.

What am I doing wrong ?

Regards,
Constantin


#2

Found the answer - preserve env. vars when running sudo:

sudo -E -u redash bin/run ./manage.py database create_tables