What’s wrong with me?

This has been going on for years but has gotten worse. Anyways I’ve been feeling kind of down and will randomly cry for no reason, I also will wake up and feel fine and then do a complete 180 and feel horrible a couple minutes later, I’m about 5 hours away from my family and my friends so I don’t get to see them often. I’ve tried making friends where I am now but haven’t been successful. Another thing that may not really have anything to do with it is that when I am home and if I’m feeling sad my dog comes and sits up by my leg or he’ll follow me everywhere. He does spend a lot of time with me but usually he gets under a blanket and stays there until he needs to use the bathroom. I’ve also been sometimes thinking about dying which scares me the most and I haven’t been able to sleep very well. I don’t know what to do or what’s wrong with me any advice?