What did the Louvre used to be?

The Louvre used to be a fortress, then a palace and then it became a museum later on.