taskcat icon indicating copy to clipboard operation
taskcat copied to clipboard

[Feature Request] debug output for Dockerfile based lambda packaging

Open gargana opened this issue 4 years ago • 0 comments

Currently builds give very little details when packaging lambdas by Dockerfile.

I would like to see container logs in the taskcat output for more complex packaging

Making the following changes to _lamda_build.py I am able to get some ugly but useful docker logs.

from io import BytesIO
from docker import APIClient
def _docker_build(self, path, tag):
        #_, logs = self._docker.images.build(path=str(path), tag=tag)
        #build_logs = []
        #for line in logs:
        #    line = self._clean_build_log(line)
        #    if line:
        #        build_logs.append(line)
        #LOG.debug("docker build logs: \n{}".format("\n".join(build_logs)))

        cli = APIClient(base_url='unix:///var/run/docker.sock')
        build_logs = [line for line in cli.build(
          path=str(path), tag=tag
        )]
        output = ""
        for line in build_logs:
            print(line.decode())
        LOG.debug("docker build logs: \n{}".format("\n".join(output)))

Problems with this approach.

  1. Directly access the UNIX socket is brittle and would break on a number of systems.
  2. Formatting of the logs is very ugly.

gargana avatar Nov 03 '21 16:11 gargana