It's not easy, but congratulations you have atleast taken the first step to recovery i.e., acknowledging it and looking at it as a problem.
Like comments above, remove all access to porn or anything that triggers the thought in you, could be anything.... Social media posts, news, magazines, ads on tv, movies, etc if anything you find triggering, stay away from it consciously.
While sleeping, always try and sleep on your back or your side as much as possible, sleeping on your belly will give you an erection and stimulate you.
Like comments above, focus your energy into something you like to do physically so that you will tire yourself and have a shower and sleep well.
All said, don't be disappointed if you slip back, it is not an overnight miracle, it is a journey.
We're all here to help you and support you, am sure you can come out successful.