I’ve spent a fair amount of cycles bringing Screenly OSE back to it’s former glory recently. As part of the update, I’ve overhauled the Balena support.
One thing that I have struggled a bit with however is build arguments. In short, because Screenly OSE requires build arguments to fully work. This is, among many things, so that we can pull in the right Qt version (which is different for the different pi boards).
As far as I can tell, there are two ways to set docker build
arguments in Balena’s pipeline.
- Using
.balena/balena.yml
(link) - Using
balena-cli
Initially, my gut feeling was that balena.yml
would be the most straight forward approach, so I wrote a little script that would generate it:
#!/bin/bash
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# -*- sh-basic-offset: 4 -*-
set -euo pipefail
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
GIT_SHORT_HASH=$(git rev-parse --short HEAD)
GIT_HASH=$(git rev-parse HEAD)
read -p "What is the target device? (pi1-pi4)? " -r DEVICE_TYPE
mkdir -p .balena
cat <<EOF > .balena/balena.yml
build-variables:
global:
- GIT_HASH=$GIT_HASH
- GIT_SHORT_HASH=$GIT_SHORT_HASH
- GIT_BRANCH=$GIT_BRANCH
services:
srly-ose-viewer:
- DEVICE_TYPE=$DEVICE_TYPE
EOF
However, since this file is unique to (almost each) build, we cannot commit it in the git
repo. Hence we need to include it in .gitignore
. This of course create a second problem: Balena will not pick it up. Unless I’m missing anything obvious here, this approach will not work.
That bring us to the next option: using the balena-cli
. This of course has other downsides, such as adding more complexity for the end-user.
I did play a bit with the source -buildArg
(link), but this doesn’t seem like a good fit. Instead, I’d like to use the push
feature, but this argument does not seem to support build arguments.
Any pointers here would be helpful.
In a perfect world, I’d like to run/set these as some sort of hook.