How do I stop my painted nails from peeling/flaking?

I've always had pretty weak fingernails. In the last few months, with the help of a nail growth serum and frequent maintenance, I've finally gotten them to consistently be long enough that you can actually see some white at the edges. (Yeah, it's always been pretty bad.)

I'm excited to be able to paint my nails and have them actually look semi-nice, but I find that nail polish seems to weaken them. They start flaking and peeling. (Not as bad as this image, but this is basically the idea.)

Does anyone know why this happens, or if there are steps I can take to prevent it? I'd love to be able to have a manicure without a two-week recovery period!