TIL you can use environment variables in your docker compose files. I use environment variables with my homelab setup as a simple way to keep secrets out of version control and reduce repeating common file paths for binded volumes. Docker compose even uses a .env file out of the box. Most shell interpolation features work too.

services:
  web:
    image: nginx
    ports:
      - "8080:${NGINX_PORT:-80}"
    environment:
      - NGINX_HOST=${NGINX_HOST:?error}
      - NGINX_PORT=${NGINX_PORT:-80}

Reference: Environment Variables in Compose