Recently, I had to implement a gallery meta box to a custom post. I found a pretty well documented blogpost, so I thought I will shear it with you, saving some time. If you find better resources for that purpose, let me know in the comment below.
@code available under the links above
See also https://rudrastyh.com/wordpress/customizable-media-uploader.html