FYI my earlier suspicions seem to be correct as preceding the build with the following command fixes the issue:
command: |
pyenv uninstall -f 3.6.5
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
pyenv install 3.6.5
if anyone experiences a similar issue you can use that as work around and cache the image though is is sub-optimal