The N.W.A. flick "Straight Outta Compton" just got christened with a drive-by shooting ... right in front of the movie crew.
Eyewitnesses tell TMZ ... the gunfire erupted outside the Compton Courthouse last week when some neighborhood guys, not actors, flashed gang signs at a passing car.
We're told the gunmen were NOT targeting the crew -- but since they were setting up outside the courthouse the bullets came dangerously close. One nearby civilian was hit, and collapsed next to the set ... but survived.
The L.A. County Sheriff's Dept. tells us the shooting is under investigation. They have not yet determined if it was gang-related.
We're told filming will continue this week in a rough area of Compton ... even though many members of the cast and crew are shaken, and worried about their safety.