I think the death penalty applies only to desertion in time of war. Our occupation of Iraq is not a declared war.
As far as joining the army goes, I think he was either stupid, extremely ignorant, or morally retarded. Who doesn't know that the purpose of the military is to kill people and destroy property?
If he suddenly had an attack of conscience, well, better late than never. Moral growth is possible. As far as his contract, well, that's a problem. It would be nice if there were a way to opt out of it, but, though options may exist on paper, we've all read or seen on TV the fate of people already in the military who apply for conscientious objector status. It just doesn't work.
This leaves desertion the only option.
As far as legality goes, laws are written by men, and men often make stupid or immoral laws. One is not obligated to observe a law just because it's a law. Conscience trumps law. One is morally obligated to disobey an immoral law.
We were certainly quick enough to condemn the perfectly legal actions of the Third Reich at Nuremberg, for example.