Preheat the oven to 350F. Grease an 8x8 inch baking dish. Set aside.
In a small saucepan, over medium heat, melt the butter.
Add the onions, garlic and thyme and cook for about 3 minutes, until the onions are tender. Set aside.
Layer 1/3 of the potato slices in the bottom of the prepared baking dish. Season with a sprinkle of salt and pepper.
Place ½ of the onion mixture evenly over the top of the potato layer.
Sprinkle ½ of the bacon evenly over the onion mixture.
Sprinkle ½ of the grated gruyere cheese over the top of the bacon layer.
Repeat these layers.
Place the remaining 1/3 of the potatoes evenly on top.
Pour the cream over the top. Cover with tin foil and bake for 1 hour.
Uncover and place the slices of brie cheese over the top of the potatoes. Cook for 30-35 minutes more, until the brie has melted and the potatoes are fork tender.
Serve sprinkled with fresh chopped parsley if desired.