You have three options:
-
You create them from pure energy via fusion of atoms.
-
Offworld.
-
Recycling.
For food there's a fourth option:
High tech approach - orbital farms, horizonal farming, farming levels in the city. If you have a city wide planet, energy is no longer a problem. Otherwise you'd not have made it that far.