Add the following commands to your postInstall script:
#!/bin/bash
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=xenial
echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" \
> /etc/apt/sources.list.d/ppa-test.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F
apt-get -qq update && apt-get install -y --no-install-recommends gcc-7 g++-7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
update-alternatives --config gcc
On Ubuntu: 18.04, installing gcc
via apt-get will install version 7.3.0 by default (from January 2019).
โ