I've got 2 MacBook Pro's. One from 2014 and I bought one in November 2016, which is a 2015 model (yes, I bought that one right before the release of the new MacBook on purpose since the new MacBook Pro is way more expensive with 'less' hardware and a sucky keyboard). The MacBook from 2014 is one which isn't actually mine, but it's one I got from my work since it's my work environment.
I'm a professional web developer, and I'm not only developing for my job, but also privately which is awesome (Game Development, Mobile App development (using Cordova), Web development, graphical designing). I'm doing more stuff which is just better to do on a Mac OSX machine, in my opinion. Because I absolutely want to seperate my work environment from my private environment - I have decided to purchase another machine (hence the second MacBook). But I have been thinking about purchasing an iMac as well instead of a MacBook. Frankly, I was also looking at the 27.5" 5K retina display.
After a lot of thinking, watching video's, etc.. I have decided to purchase another MacBook, simply due to the fact I'm very mobile. Because I am using my private MacBook as my main laptop as well I can take it anywhere I go and I'm taking it a lot of times with me. I can't take an iMac with me, it's too big and you need take a mouse and an external keyboard with you. I do love the big screen of an iMac, but I've got my monitors set-up that I can easily connect my MacBook to my external monitors for development.
For music producing I would say a MacBook would be just as good as an iMac, but it depends on if you want to be able to take your machine with you wherever you want. I do think a 27" 5K iMac would be a bit over-kill for your purpose. You can get one cheaper which is able to do the same, for example the 21,5" 3.1 GHz iMac. It has 8GB RAM as well and you have a Fusion Drive version and a non-fusion drive version. I do recommend you to get a fusion drive, since booting with an SSD is much faster and (nowadays) I think it's a requirement for such expensive machines.
The iMac is an extremely well fitting machine for music purposes, development and designing, so you're on the right track!
p/s: please note, fusion drive ONLY means your machine is booting from a small SSD. It's only 24GB and I'm not sure if you can manually install software on it, since fusion drive means it's combined with your 1TB HDD to one volume. But I might be incorrect, if I were you I'd do some research on the fusion drive for the iMac you're going to purchase.