This last week I struggled with a Docker Compose setup that used the current UID and GID to set permissions within a container, keeping the permissions intact for ease of development, and also preventing unnecessary code from running as root (within the container). This had the side effect of making it difficult (read: impossible) to deploy it, either on Digital Ocean (as a single container) or locally (as a Docker Compose group).
After that fiasco, I remembered that Simon Willison had done a lot of work with Docker, including learning how layers/caching/containers worked so he could reduce the deployment size to stay within a vendor's requirement.
Via Mr. Willison, found Nick Janetakis's article Best Practices Around Production Ready Web Apps with Docker Compose (updated 2021-06-01), which listed a tremendously useful number of tips and examples of how to use Docker and Docker Compose for development and production, while maintaining as much simplicity and preventing as many surprises as possible.
The article contains a list of his GitHub repos.
Highly recommended. And yes, the article explores working solutions to my original UID/GID problem, with the trade-offs.
Exactly the article I needed to read. (Just 1 week late for me.)