If you only have limited supplies its immoral to help somebody geographically closer than you than somebody further away?
Ceteris paribus I don't think many people would find that immoral, no.
Isn’t it clearly immoral to sacrifice the interests of the people who elected you to support another nation?
The morality argument here considers countries (defined as government + population) as actors, rather than governments. So the question is rather whether it's immoral for the people who elect a government to demand that it represents solely their interests to the point of sacrificing other people.
That’s not what is happening if it is a tragedy of the commons.
Maybe, in the sense that it could be politically destabilizing or something like that.