It isn't necessarily discrimination to have a preference for those closer to you or that you know better. Racism would require say not helping African immigrants in your own country, or those of African descent. Also, you could compare whether white people not in Europe, are being treated differently, identifying whether differential treatment is about relative locality.
Peter Singer works through many relevant thought-experiments in his book The Life You Can Save, like the drowning child in a pond example. He arrives at the idea everyone should give 1% of income to charity, and use impartial criteria yo direct this as effectively as possible. This basically amounts to the school of thought Bill Gates and others subscribe to, Effective Altruism. There are many criticisms of this approach as oversimplifying, for instance it basically says everyone should give money toward eliminating malaria because it's such a big killer, but we need a mix of strategies and some kind of coordination. And, those we understand better we can judge how to help better - tacit knowledge is crucial, and like say in Vietnam and Iraq and Afghanistan and Syria and Libya without it attempts to 'help' can be worse than useless.
Singer in his book The Expanding Circle: Ethics and Sociobiology, more convincingly makes the case moral progress has been a process of expanding our concern for the wellbeing of others. The case against racial and gender inequality was not just about the wellbeing of those impacted by say unequal laws, but about the effects of enacting and believing in those laws on those in power upholding them. We understand those who treat others fairly, eg based on evidence rather than prejudice, as more moral. And, we seem to find a society of people who choose that direction coincidentally is more creative and productive, as people with talents and ideas get to work on developing them regardless of birth. Singer makes the case that expanding moral concern to animals based on their capacities rather than prejudgement, is also moral progress. And he successfully campaigned for enhanced rights for dolphins and chimps. Exactly why this model of 'moral progress' is appealing is more complex, I think.
Rawls' theory of justice works from imagining all human situations are shuffled behind 'a veil of ignorance', and we should structure society imagining we can't know who's circumstance we would be born into. In this way of thinking, society is the transpersonal thing alloting situations, and each and every person has a deep human similarity at birth, in which they find themselves encountering society's decisions. Too late for most of us, we see how we could restructure siciety to be more just, to better serve future babies that are emerging from a true 'veil of ignorance', and by believing in justice ourselves they will hopefully have a better time, after our reforms.
I link together these ideas, of expanding our circle of concern, and creating a more just world, with our conceptual thinking being underpinned by intersubjectivity, here: Is the Categorical Imperative Simply Bad Math? :) That is, the mechanism of the appeal of Singer & Rawls theories, and of justice itself, is I think in facilitating a world in which we readily invite each other, into each others minds and situations, and so expand our minds, and our shared reality.
So that all sounds great (I hope!), we can see what justice is. Should we just overturn all previous history and accept fraternity with all humans and animals? Unfortunately, it can't be that simple.
We emerged from genes, from the replication of replicators, and they have different concerns from our minds, our meme-machines. Justice is a meme, or a meme-complex. Social insects and slime-moulds helped us to understand that kin-selection, helping closely related others even at cost of individual reproduction, can point a direction away from only genes being the unit of selection. Multi-level selection, in which both individual and group selection come to be important, can be understood as potentially leading to eusociality, a set of traits that lead to prioritising hive or pack well-being, and encompasses both social insects and hominid development. That is, it points from genes towards genes+memes.
But even including this group selection (while not discounting gene selection), that still involves a fitness landscape that chooses between groups for groups to get better. If all the ants just accept universal brotherhood, ant evolution ends. And worse, it makes sense in terms of replication of replicators, ie genes, for some ants to benefit from the group, without supporting it. This, is the free-rider problem. And we can understand it in humans, in relation to the idea of the social contract, discussed here: Is the tyrannicide perpetrated by William Tell morally legitimate? We bind together in groups, as tribes, nations, cultures, around a set of values, and there are costs and benefits. People get pretty stressed when new people want the benefits, but refuse the costs - they are being free-riders, and the stress is because they risk destabilising the group.
Sociologist Durkheim provided the first picture of what religious practice is, that could encompass shamanism, Shinto, Vedic Hinduism, Confucianism, Zen, without as had previously been the case just seeing them as faltering steps on the road to Abrahamic faiths. Discussed here: What are the origins and evolution of mythology/religions? In this view sacred values, like say habeus corpus, the right to not be imprisoned without trial, aren't just metaphorically sacred, they are literally sacred, put beyond question, and bind together a community that holds them - challenge the value, challenge the cohesion of the group. There are costs, and benefits: join for the benefits and you have to take the costs, and if those that don't accept the costs aren't rejected or constrained, the coherence of the group risks being lost. Free-riders can be from above or below, governments and authoritarians, or people joining a society on low 'rungs' who refuse to accept defining cultural values.
The examples racists point to are things like wanting to be subject to Sharia law, though it's actually a complex area and there's a long history of Jewish communities working with a hybrid of Jewish courts for civil matters and law-of-the-land in criminal matters. Honour killing is really problematic, and opposed to core values about the sanctity of life, but it is widely condemned as not in accordance with Sharia law.
Less mentioned, but I think recently brought to focus, are the cases of Russia and China and Saudi Arabia not having habeus corpus. It has a hugely corrosive effect, that I think can reasonably be said to challenge coherence of the global community, when developed nations and major economies don't uphold it. The threat of disappearance, or assassination, undermines the whole concept of rule-of-law, of a system in which case-law and precedent can allow dilemmas to be solved progressively better, and with more sophistication as challenges arise. Instead subjects to arbitrary detention have to self-censor, constantly guessing where unwritten lines might be crossed.
That doesn't mean racism doesn't exist, humans have many cognitive biases and a major role for philosophy is to challenge them, especially atavisms like racism. But, we can understand that being more welcoming of people with shared core values, fits with avoiding free-rider problems that can risk destabilising communities, but also note those dangers are very often over-hyped
(eg see the Rivers Of Blood speech).
In the international community too, it is essential to be clear core values around rule-of-law and sanctity-of-life, are critical to the 'buy in' of that global community. Making excuses when people are poisoned abroad or disappear by action of these states, because there is money to be made, just stores up trouble, for everyone.