2.9 KiB
Measure Docker image efficiency
Use the image-efficiency:* Playwright projects to measure built images with Dive 0.13.1.
These projects use the existing artifact and metrics reporters. They do not start a browser or n8n instance.
Before you start
- Install Dive 0.13.1 from its release.
- Start Docker.
- Use existing local images, or build current images with
DOCKER_BUILD_DISTROLESS=true pnpm build:docker. Redirect build output to a log file.
Run the measurements
-
Run all three image projects from the repository root:
pnpm --filter=@n8n/efficiency test:imagesTo measure only n8n, select its project:
pnpm --filter=@n8n/efficiency exec playwright test --project=image-efficiency:n8nThe defaults are
n8nio/n8n:local,n8nio/runners:local, andn8nio/runners:local-distroless. Override them withTEST_IMAGE_N8N,TEST_IMAGE_RUNNERS, andTEST_IMAGE_RUNNERS_DISTROLESS. UseDIVE_BINARYif Dive is not on yourPATH. -
Open the Playwright report:
pnpm --filter=@n8n/efficiency report -
Read
image-efficiency-summaryfor layer sizes and the largest wasted files. Usedive-reportfor the full file inventory. Useimage-identityto confirm the image ID, platform, and Dive version. Open the command step to read stdout, stderr, and the exit status when analysis fails. Image, platform, and Dive version annotations appear on the test result. -
Compare results for the same image type, platform, and Dive version. The metrics reporter sends measurements when the
QA_METRICS_WEBHOOK_*variables are configured. Theplatformdimension comes from the image, such aslinux/arm64orlinux/amd64, not the host OS. Docker images built on Apple Silicon usually uselinux/arm64.docker-image-layer-size-<image>measures uncompressed layer content in MiB.docker-image-wasted-size-<image>measures Dive's estimated wasted content in MiB.docker-image-efficiency-<image>records Dive's efficiency score as a percentage.docker-image-layer-count-<image>records the number of filesystem layers.
Layer size is not registry download size or final filesystem size. A high efficiency score can still describe a large image.
CI results
Run Test: Image Efficiency through GitHub Actions with a manual dispatch.
The standalone workflow prepares or restores the cached n8n and runners images on amd64.
Run the distroless project locally when that image is available.
The image job uploads a Playwright report and test attachments.
Currents stores results and attachments when its record key is configured.
Measurements have no size or waste budgets yet. Analysis errors and invalid reports fail the test.
Dive's JSON export bypasses its CI rules, so .dive-ci does not enforce budgets in these projects.