Unroll the pastry and cut out a circle 1cm (½ in) larger in diameter than the rim of your frying pan. Transfer pastry to a baking sheet and chill until needed. Preheat oven to 190°C (170°C convection) or 375F.
Peel and cut onions into equal size wedges through the root (this will help keep layers together).
Melt butter, oil and sugar in the frying pan. Remove pan from heat and arrange onions in concentric circles, with a cut side down. Return pan to medium heat and cook for 10-12min until onions begin to caramelise on the underside (try not to disturb wedges or they’ll lose their shape).
Add thyme, port, petimezi, garlic, and generous salt. Cook and let the onions bubble for 3 to 5 minutes, until pan juices start to thicken, then remove from heat and cool for 10min.
Carefully cover onions with the pastry circle, tucking pastry down into the sides. Make a few small slits in the pastry with a sharp knife to allow steam to escape.
Put pan into the oven for 20-25 min or until pastry is puffed and golden.
While the tart is baking, whip together all the ingredients for the feta-mastiha cream in a food processor and set aside in the fridge to firm up.
Remove the tart and let it rest at room temperature for 5 minutes, then carefully invert on to a board or plate. Garnish with more thyme, if you like, and serve hot or at room temperature, garnished with a dollop of the mastiha-feta cream.