See, I have lived in Hawai'i for 25 years now and I grew up in San Diego. So the way the Naval bases in the US work is second nature to me
But let's use Newport News. It is a town of about 180,000 people, of which something like 25, 000 work at the shipyard. It is surrounded by Joint Bases Langley-Eustis, Yorktown Naval Weapons Station, Naval Station Norfolk, Joint Expeditionary Base Little Creek-Fort Story, Naval Air Station Oceana, Norfolk Naval Shipyard and Portsmouth Naval Hospital. There's about 85000 service personnel stationed at those facilities (plus families and civilian contractors).
On top of that, there is Huntington Hall Naval Berthing Facility, which is basically a barracks & residential complex close to the shipyard where the crews of ships in for refit can stay. It isn't *in* the shipyard, but public transportation runs between there and the shipyard.
Newport News Shipyard is run by Huntington Ingalls Industries Shipbuilding. On its own, it does not have that many military personnel assigned to it (if you ignore the crews of the ships in for reactor refueling or refits). NAVSEA stations about 50 actual military personnel and another 500 civilian DoD employees there to do all the coordination and oversight needed, separate from HII's workforce.