Slow cook the onions, peel and slice the onions into semi-circles.
Melt the butter over low to medium heat.
Add in the onions, turn the heat down and allow the onions to cook for about 30 minutes until deeply golden and caramelised.
Preheat the oven.
Line a flat rectangular baking tray with parchment or grease lightly. Roll out the pastry.
Cut an indent border of about 3cm all around the edge.
Fry off the bacon lardon until crispy. Grate the cheese.
Spread the sour cream, over the base. Sprinkle over the bacon and cheese.
Spread out the slow-cooked onions over the top. Sprinkle over the thyme leaves. Brush the edges of the pastry with egg wash.
Bake in the oven for 30 minutes at 180℃ or until the pastry is crisp and the cheese is melted.