Residents living next to a nuclear submarine shipyard saw thick smoke and bright flashes as a fire broke out in the early hours of the morning.