How to define dynamic build-time variables?

I often use Dockerfile ARGs to supply a little bit of dynamic per-build information. (e.g., embedding version information into an app)

I see that balena build has a deprecated --buildArg parameter for this, but it doesn’t exist for balena push.

I see that you can define them as build-variables in balena.yml, but I was hoping to avoid writing temporary files. Before I wrap balena build and balena push with scripts that first write an unversioned .balena directory to disk: is there another way to do this?

1 Like

I’m still hoping for a better solution, but for now I’m writing to a .gitignore’d balena.yml:

#!/bin/sh

if [ $# = 0 ]; then
	echo "Usage: ./scripts/$0 version-string-here"
	exit 1
fi

VERSION_INFO=$1

mkdir -p .balena
rm -f .balena/balena.yml
cat >.balena/balena.yml <<-EOF
	build-variables:
	    global:
	        - version_info=$VERSION_INFO
EOF
1 Like