
Using Docker Compose Profiles to unit tests part of the application
Compose profiles let you group services so you can start only a subset of your stack for specific scenarios (e.g., lightweight testing vs. full production). In your docker-compose.yml , add a profiles list to each service you want to group: services : postgres : profiles : [ " core" ] ... jobrunner : profiles : [ " core" ] nextjs : profiles : [ " full" ] authserver : profiles : [ " full" ] How it works docker compose up (no --profile ) Starts only services without a profiles key. In the example above, nothing would start unless you define a default (non-profiled) service. docker compose --profile core up Starts only services tagged with core ( postgres , jobrunner ). Ideal for a lightweight testing stack. docker compose --profile full up Starts only services tagged with full ( nextjs , authserver ). Multiple profiles are supported: docker compose --profile core --profile full up This allows you to maintain one Compose file while running minimal stacks for testing or the full environmen
Continue reading on Dev.to Webdev
Opens in a new tab

