PromptFork

Generate an isolated CI test stack with docker-compose

Produces a CI-runnable docker-compose test stack with ephemeral services, deterministic data, fast teardown, and exit-code propagation, so integration tests run identically locally and in CI.

Open in Studio
Prompt
You are a senior engineer who makes CI tests reproducible and fast.

Generate an isolated CI test stack via docker-compose. Context:
- CI platform: [GitHub Actions / GitLab CI / CircleCI / generic]
- App/test command: [e.g. 'pytest -q', 'vitest run', 'go test ./...']
- Dependencies under test: [Postgres / Redis / MinIO / none]
- Test data: [seeded from fixtures / migrated fresh each run]

Produce a CI-optimized compose setup with:
1. A dedicated test profile (or a docker-compose.ci.yml override) so CI uses ephemeral config separate from local dev.
2. Ephemeral everything: no named volumes that persist across runs; tmpfs for any scratch storage for speed.
3. Pinned image versions for reproducibility, no 'latest'.
4. Healthchecks on every dependency so tests wait until ready, with tight start-period and short intervals to keep CI fast.
5. The test service that runs the suite and exits with the correct code; the compose command propagates the test exit code (run with --abort-on-container-exit or an equivalent) so CI fails when tests fail.
6. Log handling: capture enough to debug a failure, but keep output bounded.
7. A single entrypoint script (e.g. run-ci-tests.sh) that brings the stack up, waits for health, runs the suite, captures the exit code, tears down with 'down -v' even on failure, then exits with the test result.

Requirements:
- Deterministic: the same commit must pass or fail identically across runs.
- Fast: prefer tmpfs and slim test images; flag any step that would make the run slow.
- Clean: no leftover containers, volumes, or networks after a run.

Output, in this exact order:
1. The docker-compose.ci.yml with inline comments.
2. The run-ci-tests.sh entrypoint script.
3. The CI job snippet for the stated platform that invokes it.
4. A 4-item verification checklist: exit-code propagation, clean teardown, deterministic data, run-time budget.

Success signal: the output is good only if a failing test fails the CI job via exit-code propagation, teardown runs even on failure, and the stack leaves no leftovers behind.

Use case

Use when you need integration or e2e tests to spin up a real db/cache/app stack in CI, run, and tear down cleanly with a pass/fail exit code.

When to use this

When adding integration tests that need real dependencies. Not for unit tests or tests that can run against in-process fakes.

Follow-up prompts

  • Add a healthcheck gate so tests start only when dependencies are ready.
  • Generate the GitHub Actions or GitLab CI job that runs this stack end-to-end.
  • Add a test-data seeding service that loads fixtures and exits when done.
#docker#docker-compose#ci-cd#testing#devops
Source
promptfork seed
License
CC-BY-4.0
Published
6/22/2026

More prompts you might like

Scaffold a multi-service local dev docker-compose stack

Produces a clean local-dev docker-compose with app, database, and cache wired via env vars, named volumes, healthchecks, and a single command to boot everything, instead of a copy-pasted snippet soup.

#docker#docker-compose
New

Harden a docker-compose file for production-grade deployment

Produces a production-grade compose with resource limits, healthchecks, restart policies, secret handling, and log rotation, clearly scoped to single-host Docker and with its limits flagged honestly.

#docker#docker-compose
New

Next.js 15 App Router page with streaming, caching, and server data

Scaffold a production App Router page: Server Component data fetching, Suspense streaming for instant TTFB, correct cache strategy (fetch cache vs unstable_cache vs revalidatePath), loading/error boundaries, and generateMetadata — with the non-obvious patterns most tutorials skip.

New

Tailwind analytics dashboard with animated stat cards, dark mode, and skeleton loading

Production-grade dashboard layout: KPI cards with counting animations and trend sparklines, a chart area, activity table — all with dark mode, skeleton loading states, and responsive breakpoints defined to the pixel.

New

Supabase RLS: owner-write, public-read policies for a table

Generate correct, non-recursive RLS policies so anyone reads published rows and only owners edit their own.

New

Stripe webhook handler with signature verify + idempotency

Production-ready Stripe webhook route that verifies the signature and processes events exactly once.

New