Skip to content

CI: start db container before build so it warms up during build#167

Merged
stidsborg merged 1 commit into
mainfrom
ci-start-db-before-build
Jun 14, 2026
Merged

CI: start db container before build so it warms up during build#167
stidsborg merged 1 commit into
mainfrom
ci-start-db-before-build

Conversation

@stidsborg

Copy link
Copy Markdown
Owner

Summary

Swaps the order of the docker compose up and dotnet build steps in the CI workflow so the database container starts before the build, letting it warm up in parallel with the build instead of only afterwards.

New step order per matrix job:

  1. docker compose up -d <service> — DB container starts warming up
  2. dotnet build — overlaps with DB startup
  3. EnsureDatabaseConnections — retries until the DB is reachable
  4. dotnet test

Why

The database (the SqlServer container in particular) can take a while to become reachable. Previously the build ran first, then the container started cold, so the build time was wasted serially before the DB even began starting. Overlapping them shaves the DB startup off the critical path and makes the DB more likely to be ready by the time tests run.

EnsureDatabaseConnections still gates the tests via its internal retry loop, so behaviour is unchanged — this is purely a timing/ordering improvement.

Moving docker compose up ahead of dotnet build lets the database container
start up in parallel with the build, so it is more likely ready by the time
EnsureDatabaseConnections and the tests run (helps the slower SqlServer
container in particular). EnsureDatabaseConnections still gates the tests via
its internal retry loop, so behaviour is unchanged.
@stidsborg stidsborg merged commit 5698d89 into main Jun 14, 2026
8 checks passed
@stidsborg stidsborg deleted the ci-start-db-before-build branch June 14, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant