buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

Allow colourized output with docker build --progress=plain

Open captainfalcon23 opened this issue 2 years ago • 3 comments

Apologies if this isn't the write project to post this, but since "--progress=plain" is related to buildkit, thought to post here.

I am building some docker images, and want to see the entire output of the build, so I am setting "--progress=plain" which works fine, but it would be amazing if this output could be colourized. For example, I am using "set -x" to print each command, one example is having that specific output a different colour. I feel like this is already supported to some degree with "--progress=tty" but interested to hear others thoughts, or other ways we might accomplish this.

captainfalcon23 avatar Jul 12 '23 00:07 captainfalcon23

It's hard to find the colors that work well in all systems by default, so this might need an opt-in.

Anyone taking this on, you still need to check if there is an actual terminal open. Eg. docker build . 2>/log.txt should never add color codes.

tonistiigi avatar Jul 13 '23 17:07 tonistiigi

@tonistiigi there are two main considerations here:

  1. If I run the build in CI environment, I want the output colourized
  2. I think it would be good for an option where you can output the colourized output to a file and have that rendered e.g. by vim.

Also, it is technically easy to add colour to "set -x" commands (which is initially why I am raising this, see https://stackoverflow.com/questions/50989501/bash-highlight-command-before-execution-set-x. The problem is, when --progress=plain is used, the colour doesn't render (the actual escape sequences are printed), and this is the only option to view all the build logs.

Note that buildkit does support some colour for --progress=tty, but it seems to affect the docker output, not the commands running, and you can't see the entire build log.

captainfalcon23 avatar Jul 13 '23 22:07 captainfalcon23

It is very unfortunate that the collapsing tty feature is forced towards those wanted to get colors. We want colors but we don't want the BUILDKIT_TTY_LOG_LINES joys.... which is another feature that seems to be weirdly implemented. Setting to 0 does not work and even setting it to large values does not seem to work either as it deliberately decided to clean the output at random like times.

I guess that we just want a BUILDKIT_PROGRESS=color option.

ssbarnea avatar Sep 30 '24 13:09 ssbarnea