I have the perfect solution...chemical free and it works. Take some decaying fruit..if you dont have any, chop up fruit.
Put some sugar and the fruit in a clear, or at least see through, tuperware container and put the lid mostly on but leave a one inch gap from the edge of one side of the lid and the container. Let the food rot for a few days and draw their attention. Once you see the fruit flies collected in the container eating the rotted gormet...quickly...without lifting the lid or the bowl...slide the lid in place and snap tighly. Take it outside...away from the house and let them go. They will not be back. You may have to repeat this 2-3 times to get them all, but it does work
Also, Cover up your veggies with clear plastic and pick off all decaying fruit, so they will not have any food but what is in the bowl that I mentioned above. And make sure there is no standing open food or water in your house other than the bowl.
As far as where they come from...maybe the potting soil, but they are attracted to over-ripened fruit and can appear out of no where when it is present