# Build a list of commands to execute
cmds.append('docker exec ' + container +' /bin/bash -c "useradd -u ' + uid + ' ' + user + '"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "mkdir ~/.casa && mkdir -p ~/.config/pip"')
cmds.append('docker cp ' + mypath + "/config/config.py " + container +':/home/' + user +'/.casa/config.py')
cmds.append('docker cp ' + mypath + "/config/pip.conf " + container +':/home/' + user +'/.config/pip/pip.conf')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "ccache -M 50G"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "python'+ pythonversion + ' -m venv ~/venv" ')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "source ~/venv/bin/activate && pip install --index-url=https://pypi.org/simple --upgrade pip wheel"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "source ~/venv/bin/activate && pip install --index-url=https://pypi.org/simple --upgrade packaging certifi auditwheel numpy==1.19.5 scipy matplotlib patchelf"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "source ~/venv/bin/activate && cd /source/casa6/casatools/ && autoconf && ./configure && python setup.py ' + tools_target + '"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "export PATH=/usr/lib64/ccache:/opt/rh/devtoolset-4/root/usr/bin:/opt/casa/03/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/casa/02/bin:/usr/local/sbin:/usr/local/bin && source ~/venv/bin/activate && cd /source/casa6/casatools/ && autoconf && ./configure && python setup.py ' + tools_target + '"')
if tools_target=="genmake":
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "export CCACHE_DIR=/ccache && cd /source/casa6/casatools/ && make -j4' + '"')
cmds.append('docker exec -u ' + user + " " + container + " /bin/bash -c 'source ~/venv/bin/activate && cd /source/casa6/casatools/dist && auditwheel repair `ls -t *.whl | head -1`'")
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "source ~/venv/bin/activate && export PYTHONPATH=/source/casa6/casatools/build/lib.linux-x86_64-'+ pythonversion + '/ && cd /source/casa6/casatasks/ && python'+ pythonversion + ' setup.py ' + tasks_target + '"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "source ~/venv/bin/activate && export PYTHONPATH=/source/casa6/casatools/build/lib.linux-x86_64-'+ pythonversion + '/:/source/casa6/casatasks/build/lib.linux-x86_64-'+ pythonversion + '/ && cd /source/casashell/ && python setup.py ' + tasks_target + '"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "mkdir /source/extralibs"')
cmds.append('docker exec -u ' + user + " " + container +' /bin/bash -c "cp /usr/lib64/libgfortran.so.3 /source/extralibs"')