I have found that it's impossible to hermetically seal any container using normal methods, i.e. inexpensively.
I make sure that the enclosure can breathe, and that water cannot enter. If I have an issue with condensation, then make sure you have drain holes in the bottom of the box.
but condensation is not always an issue, it normally forms when something hot cools a lot and relatively quickly, so a metal box in the sun can get condensation inside in the evening as cool moist air is drawn in and the outside is cold enough to condense moisture.
Since all my outdoor enclosures are changed to plastic this has not been an issue. Grey electrical boxes work fine. If you have a situation with moisture, then a small 3 watt bulb running inside will generate enough heat to evaporate moisture.
I've had my electronics outside for years, in a large box that is open underneath, but screened to keep bugs out, and has worked well.
One caveat, do not bury boxes below where the water can rise. You can make trackside enclosures like what we call signal boxes or relay boxes.
Greg