dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

Any way to record the logs of a `compose` task? #201

Closed wimax-grapl closed 3 years ago

wimax-grapl commented 3 years ago

Docker-compose allows you to follow logs for all up'd services - something like: docker-compose logs -f -t >> myDockerCompose.log

For my project's CI, we'd love to emit the compose environment's logs as a build artifact (so we can see why a test might have failed). However, I can't quite figure out a way to robustly do this with dobi.

We basically have the following:

job=run-integration-tests:
  use: image-for-running-tests
  depends:
    - some-compose-job
  command: run_the_job.sh

the ideal case would be to emit the run_the_job.sh output to stdout, and emit the docker-compose logs to a separate stream (or file on disk). Alternatively, I'd even be fine emitting both to the same stdout - ugly, but it's something.

You can sort of get this by dobi some-compose-job:attaching simultaneously, but it runs up in addition.

wimax-grapl commented 3 years ago

We ended up writing our own script to dump the logs. https://github.com/grapl-security/grapl/blob/master/etc/ci_scripts/dump_compose_artifacts.py