Lisbon is closer to Alcobaca than Porto and there is no easy rail link between either Lisbon and Alcobaca nor Porto and Alcobaca.
You best be will be to get a flight to Lisbon and then a taxi to the Sete Rios bus station.
From their you can get a Rede Expressos bus to Alcobaca with a transit time of two hours.
Easyjet operate from Liverpool to Lisbon a few times every week.
Lisbon to Alcobaca Bus Timetable