Is it possible to apply for green card while living outside USA?

My spouse graduated from a US university recently with a PhD. And was offered and accepted a job in the gulf region. All inclusive highly paid job and no tax. (That is why we couldn’t resist it)

But, we would like to relocate to US after sometime. My question is can we apply for the green card while outside US. If we can, how do we proceed with it.
Something more to add, both of us are non US citizens/permanent residents.

So that makes things complicated right.