An ideology refers to a way of thinking. Discourse is the representation and examine of an idea through language, speech, and writing. At least, that's the way I see it to be.
A generic way of thinking is to regard discourse as an academic principle, and ideology as a belief system. But of course there are always expceptions to this.