Generally the sun, except in some case of extreme phones where some comes from chemosynthesis or geosynthesis, where the new comes from chemicals or the earth's underground heat
Nearly all of the energy that drives an ecosystem comes from the sun in the form of solar energy. Solar energy enters the ecosystem through a process of photosynthesis that is the starting point for all forms of plant and animal life on the planet. The sun and solar energy are the beginning source of energy for almost all functioning ecosystems and organisms on the planet.