You need to catch the adults and kill the eggs at the same time. For the adults: Victor "Poison-Free" Indoor Fly Trap. There's two in a box, sold at most garden centers and departments. For the eggs and larvae: any pyrethrin (Chrysanthemum oil extract) will do, I happen to like Bayer Powerforce. It contains the synthetic pyrethrin "Cyfluthrin" and can be used on fruits and vegetables up to the day of harvest:
Bayer Advanced ™ PowerForce® Multi-Insect Killer Concentrate