The commandment is actually "you shall not murder". There's a distinct difference between killing and murdering; murder can be categorised as only a small subset of killing. I could be misled but I'm under the impression that to old testament era Jews killing a non-jew was never murder.
2 This is what the Lord Almighty says: ‘I will punish the Amalekites for what they did to Israel when they waylaid them as they came up from Egypt. 3 Now go, attack the Amalekites and totally destroy all that belongs to them. Do not spare them; put to death men and women, children and infants, cattle and sheep, camels and donkeys.’