Lot of people have given good advice and im going to repeat a lot of it here.
Time is usually your friend, you need to keep your resources under safe level.
This means being active enough to either, move, spend, sell or stop production before it goes over that limit.
I would focus on building up walls and warehouses if you go this route you might find you need more resources for the next upgrade that will fit under safe level.
in those cases what you do is build up in several towns and then, when you have time you move them to the project town and immediately spend.
stopping all production and going into gold mode is a good way to about this as you'll be able to use the gold later.
you do need to make sure you keep wine in your towns enough to keep the population up though.
depending on the attacker and your defense, you can leave piece meal defensive forces,
At a minimum you should have 1 Speer and 1 slinger, and replace every time they hit the town this will at least drag the fight out for a 2nd round.
you can also add rams, gyros and bombers..but you'll have to decide if those are worth replacing all the time.
clear your ports of ships except for 1 speed boat, this will force them to occupy the port in order to keep it open, this will require them holding it with ships and costing them money in occupation, if you have a lot of cities they might not even be able to hold all your ports at one time.
if they occupy with just a few ships then what you do is build 6 bombers and 1 ram ship and then rebel, this works best if they have ships other than front line like mortars, subs and rockets.
if they occupy with just a few front line ships you can build a small number of ships (enough to destroy their fleet in 1 round) then rebel, they'll get a message their fleet was lost but not a CR so they won't even know what was in the battle, then they'll probably occupy the port with a larger fleet which will cost htem even more money.
Move the ships out of the port once you do this leaving only 1 speed boat behind, at this point you'll need to hide it some where in between use, alternatively you can just recycle them.
if they occupy with a large fleet and you have colossus this is the time where you build enough ships to start a fight (they only need to survive 1 round) then immediately hit colossus so they get booted on teh 2nd round, you can use this tactic to open your ports up if you need to move goods but make sure your timing is right, if they are active and closed by they might try to send ships into the fight.. so try to time your colossus to the last few seconds of the 1st round so that any new ships also get scattered.
you can also conduct harassment attacks on their towns but I won't go into that cause I think that's gonna be too much for you unless you want to hear about them.
Eventually they will get the hint and leave you alone at least for a while if they're not getting anything out of it their won't be any profit of any sort in it for them and tthat will take away the motivation, this works 99% of the time.. but the amount of time will vary.
But be warned this could be a temporary solution.. as even if they stop attacking you they might leave you be for say a month and then come to check on you again.