1/4teaspoonCayenne Pepper (optional, but it breaks up the richness quite nicely)
1cupPanko Bread Crumbs
Preheat oven to 350 degrees (F).
Trim the ends of both sides of the green beans; cut them in half if you prefer the pieces to be bite-sized.
Bring a large pot of lightly salted water to a rapid boil. Blanch the green beans by dropping them into the boiling water and allowing them to par-cook for 4 minutes. Remove them from the boiling water with a slotted spoon and immediately emerge them into an ice bath (a large bowl of ice cold water) to stop the cooking process. Drain the green beans once they're cool; pat them dry; and set aside.
Add bacon pieces to a large skillet over medium heat. Cook bacon for 3-4 minutes, or until it's cooked through but not crispy; remove with a slotted spoon and set aside.
Add the olive oil, thinly sliced onions, and brown sugar to the same pan the bacon was cooked in. Cook over medium-low, stirring occasionally, until the onions have deepened in color and caramelized; about 25 minutes. Stir in garlic and bacon and cook for another 2 minutes. Remove pan from heat and set aside.
In a separate skillet, melt butter over medium heat. Once it's completely melted sprinkle the flour into the pan and whisk immediately, evenly mixing it into the butter. Cook for a minute or two, then pour in milk and heavy cream. Continue cooking, whisking constantly, until the sauce thickens up; about 2 minutes. Stir in salt, pepper, cayenne, and gruyere. Stir constantly until cheese has melted completely into the sauce, then remove pan from heat. Stir the bacon/onion mixture into the cream sauce, mix well to combine.
Pour sauce over green beans and stir gently to combine. Pour the mixture into an oven-safe casserole dish, then top with panko bread crumbs.
Bake for 25-30 minutes, or until sauce is bubbling and panko crumbs are golden.