At least 28 people were killed in an attack on a military academy in the Libyan capital late on Saturday, the health minister of the Tripoli-based government said.