So the ideal of solarpunk is obviously that you would not need one, but if not every nation went in a solarpunk direction at the same time, you would likely need a defense against those that did not go in this direction and wanted the natural resources of solarpunk societies that obviously aren't as interested in exploiting their own resources.
Politically, the society is somewhat more decentralized than modern capitalist ones, but they still have a degree of quasi-national government for certain things(like a military to defend against a foreign aggressor, keeping electrified railroads between cities active, and monitoring those who might cheat on extremely strict environmental regulations). How might a military be structured for such a society?
Starfleet from Star Trek might be a source of inspiration given the shared optimistic focus, but it really doesn't work all that well. The problem is that Star Trek posits an extremely advanced society in terms of technology and especially energy output. Their reliance on starships and orbital/air power is fairly hard to adapt to a society that is deliberately relying on less energy than is required. The closest modern equivalent would be a powerful air force whose fighter squadrons pretend they are primarily for aerospace testing and airshows in support of extremely light ground forces that pretend they do something other than soldiering and thus generally lack the proper equipment to do it.
The likely enemy is a more or less cyberpunk nation that heavily uses mercenary companies to back up the government military that is one of the few things more or less funded, but for the sake of simplicity, assume a more or less modern tech level. The tech will probably advance a fair bit, but it is easier to ignore this for now and convert things later.
EDIT: The real question I think should be about how to make a military less wasteful overall. What changes would have to be made here?