I have used an all-in-one door lock/catch consisting of a solenoid and a push-to-lock type catch. Search the Internet for 'door lock electric' and you'll see examples of these.
You then need a solenoid driver. There are plenty of cheap modules available to drive your solenoid from a logic output. Make sure you put a pull-down resistor on the Raspberry Pi I/O driving it. This is so the solenoid doesn't false-trigger on power-up when the I/O pin is not yet configured as an output. Make sure you connect a reverse-biased 1N4007-or-similar diode across the solenoid coil to discharge the back-e.m.f. current when the solenoid is switched off.
The problem is does leave you with is stopping your software turning the solenoid on and leaving it on, overheating the coil, possibly dangerously so. Perfectly behaved software won't do this, nor will software using a watchdog timer correctly and reliably. Both of these don't get written very often (despite their author's beliefs).
I would solve this safety problem in hardware by having the software trigger a timer circuit that cannot be retriggered. This would generate a simple sequence: solenoid powered for (e.g.) 100 ms then solenoid off for (e.g.) 2 sec. Faulty software constantly triggering this circuit would only put a 5% duty cycle on the solenoid.