It is already progress as the interpolation error and “variable not set” warnings are gone
Do you really have the line cat << EOF >| .env
inside your .env
file if you open it in an editor? In this case, you have to remove it (remove the first and the last line completely). The content should look like this:
OWNCLOUD_VERSION=10.8
OWNCLOUD_DOMAIN=localhost
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
HTTP_PORT=8080
HTTPS_PORT=443
The cat << EOF
thing is meant to be pasted to your terminal to automatically create the .env
file with the desired config, see linux - What does <<EOF do? - Super User