Cristiano Ronaldo, Joao Felix and Rafael Leao all scored, but Portugal had to sweat out a narrow win over Ghana as their defence wobbled.