Melt the butter in a large skillet over medium-high heat. Add the onions and cook, stirring occasionally, until softened, about 10 minutes. Add the wine and continue to cook for another 5 minutes until the onions are deeply caramelized.
Add the garlic and thyme, then season with salt and pepper. Cook for another 2 minutes, then remove from the heat.
Butter a 9×13 inch casserole dish. In a large glass measuring cup, combine the cream, milk, cayenne, salt, and pepper. Add the Gruyere cheese. Pour 1/3 of the milk mixture into the bottom of the baking dish. Layer in 1/3 of the potatoes and 1/2 of the onions. Add another 1/3 of the milk mixture, then another 1/3 of the potatoes, and the remaining onions. Add the remaining potatoes and pour over the last of the milk mixture, ensuring the potatoes are in an even layer.
ADVERTISEMENT