Preheat oven to 400 degrees. On a lightly floured surface, roll pastry to 10-inch square (trim the edges with a paring knife). Fit the pastry into an 8-inch square baking pan, folding corners to fit. Prick bottom of dough with a fork. Heat a large skillet over medium-high heat. Add bacon; cook, stirring occasionally, until pieces start to brown, 4 to 5 minutes. Add onions; cook, stirring occasionally, until bacon is crisp and onions are lightly browned, 5 to 7 minutes. With a slotted spoon, transfer mixture to a plate; let cool slightly. Scatter onion mixture over pastry. In a small bowl, whisk eggs, cream, 1/4 teaspoon salt, and 1/8 teaspoon pepper. Pour egg mixture into pastry shell. Sprinkle Gruyere over top. Bake until filling is set and top is golden brown, about 40 minutes.