Create within the shipyard, additional modules, which make possible creating ships that can deploy mine fields, so that, only "allies and commercial ships" can travel (of course your own ships).
This way, you can create defensive walls for your empire.