Don't tell anyone in your workplace that you're leaving until you have that solid job offer/contract in your hands, even if they are your best friend.
If you're definitely leaving, you may even want to sign and return it first to make sure nothing puts a hurdle in the way (background checks / references / etc). It can help here to negotiate a start date that includes a little longer time than your notice period.
Then you can tell your friend first, and officially notify the company of your resignation. Explain that this new job is a great opportunity for you to grow, and if your friend really is a friend, they will see that it's in your best interest to move to a new job.
It's only if you wanted to use the job offer as a bargaining chip that you might consider telling your boss (to illicit a counter offer), but I think you should still wait until the offer it made when doing this too.