In Ravi Vakil's lecture notes ("Foundations of Algebraic Geometry", Classes 53 and 54) one can find a relative version of Serre duality (Exercise 6.1), namely:

"Suppose $\pi: X\rightarrow Y$ is a flat projective morphism of locally Noetherian schemes, of relative dimension $n$. Assume all of the geometric fibers are Cohen-Macaulay. Then there exists a coherent sheaf $\omega_{X/Y}$ on $X$, along with a trace map $R^n\pi_\ast\omega_{X/Y}\rightarrow\mathcal{O} _Y$ such that, for every finite rank locally free sheaves $\mathcal{F}$ on $X$, each of whose higher pushforwards are locally free on $Y$, $$R^i\pi_\ast\mathcal{F}\times R^{n-i}\pi_\ast(\mathcal{F^\vee\otimes\omega}_X)\rightarrow R^n\pi_\ast\mathcal{\omega}_X\rightarrow\mathcal{O}_Y$$ is a perfect pairing."

For citing purposes, I'd like to have a more canonical reference (i.e. paper or textbook) of this result, but was yet unable to find any. Moreover, I'd actually like to have that result for a flat proper morphism instead of a flat projective morphism. Is it also true in this case?

I'm sorry if this question is trivial, I'm not really familiar with algebraic geometry. Thank you!