I have switched from working in bedroom, to working in a dedicated office, to working in a co-working space, to working from home in a dedicated office. 1. Working from the bedroom is hell. It's fun for the first few months but then you are likely to have severe eye strain and become very sleepy. 2. Working from a real office sets boundaries and forces a schedule. You have to wake up at xx:xx time and drive to office…
I have been on a similar journey and now rent an office in small town centre (10 minutes drive from home). It gives me the discipline to work set hours and also the freedom to walk around where other people are going about their business so I don't feel isolated. It's also useful for shops, cafes, bars (for after work) and such.
No solution is ever going to be ideal but this is the nearest I have come so far.