Mount Nissedal mirror away from the wall
If you insist on building the entire project, you should use standard lumber boards to construct a box around the shelves. Anything less than an enclosing box will not be strong enough to support and withstand the forces incident to opening and closing a hinged door. 

To attach the box to the wall, use internal crosspieces at the back of the top and bottom. Screw through the crosspieces into the studs (you'll want to find those for hanging the shelves anyway). 

If you want to skip most of the building, you'll find that medicine cabinets are rarely more than about 15cm deep. They're usually designed to fit into a wall between the studs. 

Also, I don't know where you are, but around here in New England I have found in furniture outlets many shallow cabinets obviously intended as surface mounted medicine cabinets. Apparently sometimes builders do not want to cut into the bathroom wall.