Stretch your foot before you get out of bed or get up after being off it for any period of time. You need to stretch and warm up the tendons. When you sleep they tighten up and if you jump up to answer the door or natures call without first warming up by stretching it will tear and you are back to square one.
I was plagued with it and the stretching, particularly when I had been inactive, seemed to work. That and decent shoes and insoles helped me. I have not had a re-occurrence in 5 or more years.