Lewis Hamilton will join Ferrari for the 2025 F1 season as the seven-time champion targets a record eighth world title.