Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Dockerfile Optimise

  • 264 installs
  • 191 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

dockerfile-optimise: A skill for development. This provides functionality for development workflows.

Key points

  • dockerfile-optimise

Dockerfile Optimise by the numbers

  • 264 all-time installs (skills.sh)
  • +5 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #1,467 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill dockerfile-optimise

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs264
repo stars191
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do I use dockerfile-optimise for development tasks?

Use dockerfile-optimise for development tasks

Who is it for?

Best when you're working on backend & apis and need structured help with dockerfile-optimise.

Skip if: Teams with no backend & apis needs, or anyone wanting a generic chat assistant without this specific workflow.

When should I use this skill?

When you need to use dockerfile-optimise for development tasks, or when dockerfile-optimise: a skill for development. this provides functionality for development workflows.

What you get

Structured output aligned to dockerfile-optimise: dockerfile-optimise.

Files

SKILL.mdMarkdownGitHub ↗

Dockerfile Optimization Best Practices

Comprehensive Dockerfile optimization guide sourced exclusively from official Docker documentation. Contains 48 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new Dockerfiles or modifying existing ones
  • Optimizing Docker build times (layer caching, cache mounts, context management)
  • Reducing Docker image size (multi-stage builds, minimal base images)
  • Hardening container security (secret mounts, non-root users, attestations)
  • Setting up CI/CD pipelines with Docker builds
  • Reviewing Dockerfiles for anti-patterns

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Layer Caching & OrderingCRITICALcache-
2Multi-Stage BuildsCRITICALstage-
3Base Image SelectionHIGHbase-
4Build Context ManagementHIGHctx-
5Security & SecretsHIGHsec-
6Dependency ManagementMEDIUM-HIGHdep-
7Instruction PatternsMEDIUMinst-
8Quality & ValidationMEDIUMlint-

Quick Reference

1. Layer Caching & Ordering (CRITICAL)

  • `cache-layer-order` - Order layers by change frequency
  • `cache-copy-deps-first` - Copy dependency files before source code
  • `cache-copy-link` - Use COPY --link for cache-efficient layer copying
  • `cache-mount-package` - Use cache mounts for package managers
  • `cache-apt-combine` - Combine apt-get update with install
  • `cache-external` - Use external cache for CI/CD builds
  • `cache-invalidation` - Avoid unnecessary cache invalidation
  • `cache-minimize-layers` - Consolidate related RUN instructions

2. Multi-Stage Builds (CRITICAL)

  • `stage-separate-build-runtime` - Separate build and runtime stages
  • `stage-named-stages` - Use named build stages
  • `stage-parallel-branches` - Exploit parallel stage execution
  • `stage-target-builds` - Use target builds for dev/prod
  • `stage-copy-artifacts-only` - Copy only final artifacts between stages
  • `stage-reusable-base` - Create reusable base stages

3. Base Image Selection (HIGH)

  • `base-minimal-image` - Use minimal base images
  • `base-official-images` - Use Docker Official Images
  • `base-pin-versions` - Pin base image versions with digests
  • `base-arg-version` - Use ARG before FROM to parameterize base images
  • `base-rebuild-regularly` - Rebuild images regularly with --pull
  • `base-distroless` - Use distroless or scratch images for production

4. Build Context Management (HIGH)

  • `ctx-dockerignore` - Use .dockerignore to exclude unnecessary files
  • `ctx-bind-mounts` - Use bind mounts instead of COPY for build-only files
  • `ctx-minimize-context` - Keep build context small
  • `ctx-syntax-directive` - Use syntax directive for latest BuildKit features (prerequisite for cache mounts, secret mounts, heredocs, COPY --link)

5. Security & Secrets (HIGH)

  • `sec-secret-mounts` - Use secret mounts for sensitive data
  • `sec-non-root-user` - Run as non-root user
  • `sec-no-secrets-in-args` - Never pass secrets via ARG or ENV
  • `sec-ssh-mounts` - Use SSH mounts for private repository access
  • `sec-attestations` - Enable SBOM and provenance attestations
  • `sec-no-unnecessary-packages` - Avoid installing unnecessary packages
  • `sec-ephemeral-containers` - Design ephemeral, stateless containers

6. Dependency Management (MEDIUM-HIGH)

  • `dep-cache-mount-apt` - Use cache mount for apt package manager
  • `dep-cache-mount-npm` - Use cache mount for npm, yarn, and pnpm
  • `dep-cache-mount-pip` - Use cache mount for pip
  • `dep-version-pin` - Pin package versions for reproducibility
  • `dep-cleanup-caches` - Clean package manager caches in the same layer

7. Instruction Patterns (MEDIUM)

  • `inst-json-cmd` - Use JSON form for CMD and ENTRYPOINT
  • `inst-healthcheck` - Define HEALTHCHECK for container orchestration
  • `inst-heredoc-scripts` - Use heredocs for multi-line scripts
  • `inst-entrypoint-exec` - Use exec in entrypoint scripts
  • `inst-workdir-absolute` - Use absolute paths with WORKDIR
  • `inst-copy-over-add` - Prefer COPY over ADD

8. Quality & Validation (MEDIUM)

  • `lint-build-checks` - Enable Docker build checks
  • `lint-pipefail` - Use pipefail for piped RUN commands
  • `lint-labels` - Use standard labels for image metadata
  • `lint-sort-arguments` - Sort multi-line arguments alphabetically
  • `lint-single-concern` - One concern per container

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions - Category structure and impact levels
  • Rule template - Template for adding new rules

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information

Related skills

FAQ

What does dockerfile-optimise do?

dockerfile-optimise: A skill for development. This provides functionality for development workflows.

When should I use dockerfile-optimise?

When you need to use dockerfile-optimise for development tasks, or when dockerfile-optimise: a skill for development. this provides functionality for development workflows.

What are the main capabilities?

dockerfile-optimise.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.