Work on 2014-07-10
I spent about an hour tonight working on flexible configurations for testing Kallithea against various databases using Fig and Docker
Fig handles some of the dirty work of linking together Docker
containers. Linked containers get environment variables set to define
endpoints of the other containers. They use
Django as an example
and things look pretty easy: since the configuration file is written
in python, we can just call os.environ.get('DB_1_PORT_5432_TCP_PORT')
.
No such luck with Pylons and Pyramid, though: there we use an ini file for configuration. I ran into a few bumps, though.
The paster serve
command provides an avenue for command line
configuration: var=value
can be repeated to pass in configuration
options on the command line, and the named vars can be referenced in
the ini file with %(var)s. That’s good.
Fig doesn’t seem to support environment variables in it’s YAML
configuration files, so paster serve test.ini
dbhost=$DB_1_PORT_5432_TCP_ADDR
results in a literal string
“DB_1_PORT_5432_TCP_ADDR” in the configuration. That’s bad,
but it can be fixed with a wrapper script.
Kallithea’s setup-db command doesn’t support the same var=value
setting on the command line that paster serve
supports. That’s bad,
but the wrapper script can rewrite the configuration files rather than
pass in values via arguments. That’s where I’m leaving off for tonight.
One other dangling question: I tried putting my Dockerfile and
Fig yaml configurations in a subdirectory to keep the project root
uncluttered, but it didn’t look like Docker liked using ..
in place
of .
. I need to confirm that: there’s a chance that something else
was out of line that I didn’t notice.
EDIT: turns out that relative paths really aren’t allowed. That didn’t take long to find.