A new compact gamma-ray spectrometer was developed in order to optimise the measurement of bremsstrahlung radiation emitted from runaway electrons in the MeV range. The detector is based on a cerium doped lutetium-yttrium oxyorthosilicate (LYSO:Ce) scintillator coupled to a silicon photomultiplier and is insensitive to magnetic fields. Adedicated electronic board was developed to optimise the signal readout as well as for online control of the device. The detector combines a dynamic range up to 10 MeV with moderate energy non-linearity, counting rate capabilities in excess of 1 MHz, and an energy resolution that extrapolates to a few % in the MeV range, thus meeting the requirements for its application to runaway electron studies by bremsstrahlung measurements in the gamma-ray energy range.