Before we look at any YAML, we must justify using Docker at all. Your Dockerfile is the most important part of this entire setup.
- It Guarantees Reliability: The
ubuntu-latestagent is a "floating" environment. Microsoft updates it constantly. YourDockerfilecreates a locked, immutable environment that guarantees you have PHP 8.3, thegdandpdo_mysqlextensions,composer, and theacli—today, tomorrow, and a year from now. This ends all "it broke on Monday" bugs. - It Ensures Portability: When a build fails, a developer can't debug the
aws-ubuntu-latestagent on their laptop. But they can rundocker buildlocally. This eliminates "it works on my machine" and lets developers reproduce and fix CI failures in minutes. - It's Actually Faster: The "no-docker" approach is a trap. You would have to waste time in every single job running
apt-getandcurlto installacliand your extensions. By pre-baking them into an image, your tools are instantly available.