Melt butter in a large pot over medium high heat. Add onions, shallot, garlic, bay leaves, sea salt, and black pepper and cook, stirring frequently, until onions and shallots are translucent.
Turn heat down to medium low and continue to cook, stirring occasionally, until onions and shallots are a deep golden brown (approx 20 min).
Stir in flour and cook for 1 minute before adding wine. Stir well and cook 2 more minutes.
Add stock/broth and thyme. Simmer uncovered for about 30 minutes, stirring occasionally.
While the soup simmers, preheat oven to 350 degrees. Arrange bread slices on a baking sheet and toast for 15 minutes, turning over halfway through cooking. (Bread should be dry with a slightly soft center that still springs back when touched)
Once soup is ready, preheat broiler.
Ladle soup into oven safe ramekins* (leave 1/4-1/2" at the top). Add 1 slice toasted bread to each, then top with sliced of Gruyere and a sprinkle of Parmigiano-Reggiano.
Place ramekins on a rimmed baking sheet and broil for a few minutes, until cheese is melted and bubbly.
Serve immediately, topped with a crack of black pepper and fresh thyme leaves.
Extra stores well in the fridge and tastes even better the second day!