Long-time behavior of the one-phase Stefan problem in periodic and random media