You must become a permanent resident of the United States first. If you are able to get a green card and establish U.S. residency, then you are free to join the U.S. military. You should know too that the U.S. military does not assist in the Immigration process--you must complete it on your own before you try to enlist.