balena-cli icon indicating copy to clipboard operation
balena-cli copied to clipboard

Dockerfile ARG support for local push (build arguments, --buildArg)

Open zrzka opened this issue 7 years ago • 3 comments

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"

zrzka avatar Jul 06 '18 12:07 zrzka

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.

pdcastro avatar Jan 22 '19 00:01 pdcastro

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

pdcastro avatar Feb 05 '21 16:02 pdcastro

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

This would solve the problem if only there was an option to specify a different config to use for local push.

kd496 avatar May 24 '22 13:05 kd496