docker-optimisations

Reorder Dockerfile layers to improve build cache efficiency.

31|4|Updated Aug 24, 2021
One-click install
npx skills add https://github.com/razorpay/trino-gateway --skill docker-optimisations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-optimisations
Source: https://github.com/razorpay/trino-gateway/tree/main/.agents/skills/docker-optimisations
Command: npx skills add https://github.com/razorpay/trino-gateway --skill docker-optimisations

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Optimises Dockerfiles in a repository to improve build cache efficiency by reordering layers so static, rarely-changing instructions are at the top and build-specific ARGs/ENVs come after the cache boundary.

Core Features & Use Cases

  • Reorders static and cache-busting layers to maximize Docker cache hits and reduce rebuild times.
  • Consolidates duplicate package installations and enforces a robust builder/distributor stage ordering.
  • Applies proven caching patterns across multiple Dockerfiles while preserving exact functionality.

Quick Start

Run the optimiser on a repository with /docker-optimisations optimise <service-name> [--branch <branch-name>].

Frequently Asked Questions about docker-optimisations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I speed up Docker builds by reordering Dockerfile layers?

Reduce Docker build times by consolidating package installations, enforcing builder and distributor stage ordering, and applying cache-busting boundaries around ADD or COPY instructions to ensure deterministic builds while preserving exact functionality.

What is the best way to handle static ENV placement and secrets in a Dockerfile?

Handle static ENV placement by moving it before the cache-busting boundary, and manage secret handling for tokens by applying anti-pattern rules that satisfy project guidelines without exposing secrets in the build cache.

Can I optimise multiple Dockerfiles across different build stages in one repository?

Yes, you can optimise multiple Dockerfiles across builder and distribution stages by applying proven caching patterns, reordering static layers, and pinning proto commits according to project guidelines while preserving functionality.

Why does my Docker build cache break when I add new files or change arguments?

Docker build cache breaks when build-specific ARGs or ENVs are placed before static layers, or when cache-busting boundaries around ADD or COPY instructions are not properly defined to separate static content from build-specific changes.

Do I need multiple Dockerfiles to use docker layering optimisations?

No, you do not need multiple Dockerfiles, but the optimiser targets repositories with multiple Dockerfiles across builder and distribution stages to apply anti-pattern rules for deterministic builds and improved cache efficiency.