A lot of projects split their setup into a base compose file and an override per environment. A Portainer stack from Git can read both, through a field called Additional paths.
When you create a stack with the Git repository build method, you fill in the Compose path, the path of the main compose file from the root of the repository. Below it, Additional paths lets you add more YAML files. Portainer’s docs say they’re handled the way docker compose handles several -f options, with the same merge rules.
Compose path: docker-compose.yml
Additional paths: compose.prod.yml
That matches what I’d run on a server by hand:
docker compose -f docker-compose.yml -f compose.prod.yml up -d
So the production file only needs the differences: other ports, extra volumes, a different image tag. I like keeping it like that, because the base file then works for local testing without any changes.
The order matters. Later files override earlier ones, so a value in compose.prod.yml wins over the same value in the main file, while lists like ports are combined rather than replaced. Before this goes into Portainer, check the combined result locally with docker compose -f docker-compose.yml -f compose.prod.yml config. If that output looks wrong, the stack will look wrong too.
Further reading: Portainer docs: add a new stack, Docker docs: merge Compose files