Lack of variable substitution alternatives

Hi all,

So I’ve been using balena for testing and deployment of a beta product of which is only in use at one location. Once we start spinning up more locations, each device will need its own custom configuration for things like database passwords.

I immediately thought of using environment variables at the device level in balena cloud to programmatically set a random password then in the compose file, it would use that env var (${DBPASS}). I found out that this substitution feature is not yet implemented.

Does anyone have any work around or maybe an ETA on variable substitution? Ideally, my compose file just references the device variable which would be set through the API but of course it’s using the literal name of the env var rather than the value.

Hi @jordan-lumley, as far as I’m aware we are not currently working on allowing env var substitution, main reason being there isn’t a straightforward way of solving it for the various environments where builds can occur (cloud, cli, git, etc).

What I would do as a workaround is to set the password (or whatever variable) to the env var on your application code, for instance if you are using nodejs with process.env. If you don’t have access to the application source code or can’t modify it for some reason then you can add a startup script to your docker container and start the database binary from there. It would look something like this:

start.sh:

#!/bin/bash

dbbinary --password "$DBPASS"

Dockerfile

FROM dbimage

COPY start.sh start.sh
# CMD [ "dbbinary" ]
CMD [ "/bin/bash", "start.sh" ]