Place the bread in a buttered ovenproof skillet, a 9" square baking dish, or casserole. Scatter the onion and bacon over the bread. Pour the wine over the onion and bacon and sprinkle with the cayenne and Gruyere.
Bake until the cheese has melted and begun to brown at the edges, about 20 minutes.