dnephin / dobi

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

Add signal handler for handling a TTY resize #155

Closed stumoss closed 5 years ago

stumoss commented 5 years ago

This fixes an issue whereby the terminal doesn't get given a size by dobi and therefore it can be problematic to type long commands in an interactive terminal.

Reproduction Example:

  1. Create a Dockerfile with the following contents: FROM debian:latest
  2. Create a dobi.yaml with the following contents:
    image=debian:
    image: debian
    dockerfile: Dockerfile.debian
    job=debian-job:
    use: debian
    interactive: true
  3. Run dobi debian-job
  4. Run stty size

You should end up with the following result before this fix:

dobi debian-job
[WARN] meta.project is not set. Using default "Downloads".
[image:build debian] debian is fresh
[job: debian-job] Start
root@e5fc2dff86db:/# stty size
0 0
root@e5fc2dff86db:/# 
  1. Hold down a key to repeat typing for a while and you will see that the line wraps back to the beginning of the same line (doesn't perform a carriage return properly) and you will end up with the terminal overwriting the current line with the newly typed data. You can see in the example output below that the root@0e part of the terminal prompt has been overwritten with 'a':
    dobi debian-job
    [WARN] meta.project is not set. Using default "Downloads".
    [image:build debian] debian is fresh
    [job: debian-job] Start
    root@0e83d5bbc229:/# 
    aaaaaae83d5bbc229:/# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

After the fix is applied (obviously the stty size result will depend upon the actual terminal size):

github.com/dnephin/dobi/dist/bin/dobi debian-job
[WARN] meta.project is not set. Using default "Downloads".
[image:build debian] debian is fresh
[job: debian-job] Start
root@854a6c77cf0d:/# stty size
65 273
root@854a6c77cf0d:/# 
dnephin commented 5 years ago

Thanks for fixing this!

We'll need to get the cross build working for windows, but otherwise I think it looks great