TL;DR Is that is is definitely possible on a boat. It's easier if you run the compressor on petroleum fuels but solar is possible with how inexpensive solar panels and lithium iron phosphate (LiFePO4) batteries have become. Although mounting a lot of solar on a boat is difficult unless the boat is big and wide.
Our sailboat (catamaran) came with a dive compressor in one hull and a diesel generator in the other hull. The dive compressor is a Bauer Junior II-B converted to 230v single phase (I wish they had gone 3 phase with a VFD but I don't think VFDs were as readily available and inexpensive as today).
The generator is a 7kw Onan 230v which is long in tooth but working reliably for now. I'd like to be able to run the compressor off of solar just in case it dies. Right now, our "house" or main battery bank is dying lead acid so I definitely can't run the dive compressor off of those. But shortly I'm replacing them with lithium ion and adding more solar panels and then in theory, if I add a 3 phase motor and VFD to the Bauer compressor to reduce the startup current, I should be able to run it off of our battery bank and inverter (a 3kw Victron charger inverter which can briefly go to 6kw). I'd like to do the same with our 230v watermaker. Both of these devices are high power consumption so I suspect we'd not have enough power coming in to run them freely but at least we could make water until we got somewhere we could replace the generator. Or maybe we should carry around a small honda gas powered generator as a backup (but I don't like the idea of handling gasoline that much around a highly flammable fiberglass boat).
Something to think about! There is a Youtube channel with a video where the guy converted the Bauer Junior II to 3 phase with a VFD and he is on a smaller monohull. I think he calculated 1.5kw to fill a dive tank (I think 80cf but not 100% sure, I remember estimating my fills with 12L might be closer to 2kw). At 1.5kw, we're talking 1,500 watts / 12 volts = 125 amp hours. Lithium batteries are fairly inexpensive these days if you DIY with the big cells like EVE MB31 (~300 AH) or MB56 (~600AH). If you can mount enough solar (see catamaran), it's definitely possible depending on how much you dive or if you're willing to adjust your diving to match your production. On our boat, we currently have roughly 1,200 watts of solar and once we do the upcoming work, we should be adding another 1,400 watts so we're up to 2,600 watts. Some ideal case math (not real world) is 2,600 watts / 12 volts = 216.6 amps per hour coming in during peak. In reality, we'll say maybe 3/4 of that plus charing voltage is more like 14 volts so:
2,600 watts / 14 volts * 3/4 real world = ~140 amps
In a day in the tropics, in the winter we probably get peak 4 hours so 560 amp hours plus maybe non-peak another 3 hours (let's roughly estimate that at 1/3 of 140 AH peak) so another 140 amp hours makes 560 + 140 = 700 amp hours.
Now our boat itself with a fridge, freezer, water cooling pump used by both of those and a 2nd generation Starlink dish consumes about 18 AH plus misc fans/lights we're talking roughly 20 AH. So in a 24 hour cycle we would use 480 AH. So 700 AH - 480AH = 220 AH left over going into the batteries. Or a bit less than two tanks per day fill or running the water maker for two hours (I suspect the energy consumption will be roughly the same).
That is for winter.
For summer, I think we are seeing roughly 40% more power generation so we would have 560 * 1.4 = 784 AH per day minus the 480 AH consumption = 304 AH left to play with.
If you add a big enough battery bank -- ie in our case I think we will go with three 12v batteries made with EVE MB56 LifePO4 cells (each battery uses 4 cells so 3 x 4 = 12 cells), we should have ~ 600 AH per battery * three batteries = 1800 AH storage capacity. That should let us not waste any solar production or generator run time (this is already long but right now while the generator can make 7kw, I can only get about ~120 amps at 14v into the batteries or 1,680 watts of that 7,000 watts). The nice part about all this is when we near full battery, I can run the water maker or fill some dive tanks.
Hopefully, that isn't too much of a deep dive. I've probably made some mistakes in my calculations above but the numbers should be roughly right if maybe slightly pessimistic. Some people add much more solar to their catamarans (ie 4,000+ watts) on maybe a 44-50 foot boat. Oh, and I say catamaran because the width of a catamaran makes it much easier to add a lot of solar.
Of course, if the generator keeps working or if I replace it when it dies, the numbers are all much better. I'll see how it goes with more solar and lithium batteries but I suspect I would replace the generator if it dies. But this setup should make it so I can hold off on replacing the generator until we get somewhere where such a generator is more readily available. And in that situation, I would be focused more on ensuring we had enough water (fillter scuba tanks would be a secondary concern).
Lastly, I know one local boat that is switching from an electric dive compressor to a gas powered one because they don't want to add more solar and batteries. So maybe that is a better option depending on your situation. I want the increased capacity for making water and other household uses like cooking and clothes washer. The ability to compress air for scuba is a nice side benefit. So it's worth it to me to invest in more solar and better and bigger batteries.