We can define thermodynamic equilibrium and formulate zeroth law of thermodynamics for static spacetimes, when the metric could be written as:
$$
ds^2=-g_{00}dt^2+g_{ij}dx^idx^j.
$$
At equilibrium the matter also would be static, but unlike the flat space the temperature (as measured by thermometer at given point) would gain spatial dependence, $T(x)$, of the form:
$$
T(x)=\frac{T_0}{\sqrt{|g_{00}|}},
$$
where $T_0$, the red-shifted temperature, has the meaning of a temperature at a point where gravitational potential is zero (and so the $|g_{00}|=1$). It is this red-shifted temperature that is constant across the region of thermal equilibrium. This spatial dependence of temperature is known as Tolman temperature gradient (after R.C. Tolman who discovered this effect in 1930).
For a modern discussion of the effect see:
What does the zeroth law of thermodynamics <…> mean over here?
It means that thermodynamic equilibrium introduces an equivalence relation between thermodynamic (sub)systems. The precise nature of thermal contact between systems A and B does not matter: it could be photon radiation within the reservoir enveloping both A and B, or vibrational degrees of freedom of some solid conductive material stretching between A and B, or gas of massive particles, or a sequence of different subsystems etc., as long as we know the temperature at one point, Tolman relation gives us equilibrium temperature everywhere else.
More details, discussions and related results could be found in PhD thesis of J. Santiago:
- Santiago, J. (2019). On the Connections between Thermodynamics and General Relativity, PhD thesis, Victoria University of Wellington, arXiv:1912.04470.