When you file Form 1040NR you cannot file jointly with your spouse. There is only one exception to this rule as outlined below.
Per IRS Publication 519 U.S. Tax Guide for Aliens, page 54:
I am a nonresident alien. Can I file a joint return with my spouse?
Generally, you cannot file as married filing jointly if either spouse was a nonresident alien at any time during the tax year.
However, nonresident aliens married to U.S. citizens or residents can choose to be treated as U.S. residents and file joint returns. For more information on this choice, see Nonresident Spouse Treated as a Resident in chapter 1.
If you fall under this exception, you should then be filing Form 1040 per the IRS Instructions for Form 1040NR, Page 10.
Note that any link in the information above is updated each year automatically and will take you to the most recent version of the document at the time it is accessed.