Melt butter and olive oil together in a sizable saucepan over a medium heat. Add the sliced onions, cooking and stirring them sporadically, until they achieve a caramelized texture and color. This process should approximately span 30 minutes.
Continue cooking for an additional two minutes after incorporating the minced garlic.
Ensure that onions coated in flour are thoroughly mixed.
Add thyme, bay leaf, and either beef or vegetable stock. Once it comes to a boil, reduce the heat, cover, and allow to simmer for 20 minutes.
Preheat the oven to 350°F (180°C).
Place 1-inch thick slices of sourdough bread on a baking sheet. Sprinkle grated Gruyère and Parmesan cheese over each slice.
Bake for approximately 10 minutes, or until the cheese is melted and bubbling.
Remove the sprig of thyme and bay leaf from the soup. Season with salt and pepper to your liking.
Ladle the soup into bowls and serve with the cheesy sourdough melts placed on top.