Dockerfile ARG support for local push (build arguments, --buildArg)
Description
I have a project where Dockerfile.template builds artifacts in release mode. It defaults to this behavior, so, whever I git push resin master, production build is deployed to all devices.
To make it simple, let's focus on one command only (it's more complicated, but this one is enough to demonstrate the problem). Build is done via:
RUN cargo build --release
In case of resin local push, I'd like to have debug build (without --release). What can I do now?
ENV
ENV CARGO_BUILD_COMMAND cargo build --release
resin local push --env "CARGO_BUILD_COMMAND=cargo build" doesn't work. It prints cargo build --release if I add RUN echo $CARGO_BUILD_COMMAND.
Replacement
I can do fancy stuff with sed. But it's not ideal.
ARG support
What I'd like to do is ...
ARG cargo_build_command=cargo build --release
... and then ...
resin local push --build-arg "cargo_build_command=cargo build"
The balena build and balena deploy commands have a --buildArg flag, and balena push could follow the same pattern. And not just local push, but push to the balenaCloud builders as well.
For the benefit of anyone reaching this issue: while a --buildArg flag is still not available, note that it is currently possible to specify build variables and secrets using a .balena/balena.yml file, as documented on this page: https://www.balena.io/docs/learn/deploy/deployment/#build-time-secrets-and-variables
For the benefit of anyone reaching this issue: while a
--buildArgflag is still not available, note that it is currently possible to specify build variables and secrets using a.balena/balena.ymlfile, as documented on this page: https://www.balena.io/docs/learn/deploy/deployment/#build-time-secrets-and-variables
This would solve the problem if only there was an option to specify a different config to use for local push.