You might be interested in Biosphere 2 or other Artificial ecosystems, which attempt to answer this.
While the results were impressive
closure experiments set world records in closed ecological systems
The ecosystem was far from stable indefinitely.
First attempt had unexpected interaction between atmosphere and the concrete:
carbon dioxide was reacting with exposed concrete inside Biosphere 2 to form calcium carbonate, thereby sequestering both carbon and oxygen
The second mission had some other problems, which are not very clear to me and seem to include some controversis, some of them being of organizational nature:
The ownership and management company Space Biospheres Ventures was officially dissolved on June 1, 1994.
The second mission began on March 6, 1994, with an announced run of ten months
Mission 2 was ended prematurely on September 6, 1994
TLDR: Creating stable ecosystem is extremely difficult and the only long term stable ecosystem known so far is the Earth.