{
    "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build",
    "locale": "en",
    "title": "multi-stage build: Knowledge hub | DeLaParra Services",
    "description": "Using several FROM stages in one Dockerfile — build in a fat stage, then copy only the artefacts into a tiny final stage.",
    "alternates": {
        "en": "https://delaparra-services.nl/knowledge-hub/multi-stage-build",
        "nl": "https://delaparra-services.nl/nl/kennisbank/multi-stage-build"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.csv",
        "md": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.md",
        "json": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.json",
        "zip": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.zip",
        "pdf": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.csv",
            "encodingFormat": "text/csv",
            "name": "multi-stage-build.csv"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.json",
            "encodingFormat": "application/json",
            "name": "multi-stage-build.json"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.md",
            "encodingFormat": "text/markdown",
            "name": "multi-stage-build.md"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.pdf",
            "encodingFormat": "application/pdf",
            "name": "multi-stage-build.pdf"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.zip",
            "encodingFormat": "application/zip",
            "name": "multi-stage-build.zip"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build/skills.zip",
            "encodingFormat": "application/zip",
            "name": "multi-stage-build-skills.zip"
        }
    ],
    "markdown": "1. [Home](<https://delaparra-services.nl/>) \n1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) \n1. [multi-stage build](<https://delaparra-services.nl/knowledge-hub/multi-stage-build>)\n\n  \n\nCategory: Docker \n\n# multi-stage build\n\n  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    \n\n## What is multi-stage build?\n\n \n\nmulti-stage build: Using several FROM stages in one Dockerfile — build in a fat stage, then copy only the artefacts into a tiny final stage. A multi-stage Docker build uses several ` FROM ` instructions in one Dockerfile. Early stages contain the tools needed to build, such as Node, Composer or a compiler. The final stage copies in only the finished results.\n\n \n\nDefinition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)\n\n \n\n## Frequently asked questions about multi-stage build\n\n  \n\n### How is multi-stage build used in practice?\n\n \n\nThe outcome is a much smaller production image without build tools, source maps or development dependencies. That means faster deploys and less for an attacker to work with.\n\n    \n\n### What should you keep in mind with multi-stage build?\n\n \n\nA typical PHP setup has a stage that builds front-end assets with Node, one that installs Composer dependencies, and a final PHP image that copies both in. Name stages with ` AS ` and copy with ` COPY --from=assets `. Each stage is cached separately, so changing PHP code does not rebuild the front-end assets, which keeps builds quick.\n\n    \n\n### What does an example of multi-stage build look like?\n\n \n\n```\nFROM golang:1.23 AS build WORKDIR /src COPY . . RUN go build -o app FROM gcr.io/distroless/base COPY --from=build /src/app /app ENTRYPOINT [\"/app\"]\n```\n\n \n\n## At a glance\n\n   CategoryDocker Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026\n\n \n\n## More Docker terms\n\n \n\n- [host](<https://delaparra-services.nl/knowledge-hub/host>) \n- [image](<https://delaparra-services.nl/knowledge-hub/image>) \n- [layer](<https://delaparra-services.nl/knowledge-hub/layer>) \n- [networks (compose)](<https://delaparra-services.nl/knowledge-hub/networks-compose>) \n- [none](<https://delaparra-services.nl/knowledge-hub/none>) \n- [port mapping](<https://delaparra-services.nl/knowledge-hub/port-mapping>)\n\n \n\n[All terms starting with M](<https://delaparra-services.nl/knowledge-hub#letter-m>)\n\n \n\n## Skills\n\n \n\n- ### Docker Build Strategies\n\n \n\nUse this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization.\n\n [View skill](<https://delaparra-services.nl/skills/docker-build-strategies>) [Download zip](<https://delaparra-services.nl/skills/docker-build-strategies/download>) \n- ### Multi Stage Dockerfile\n\n \n\n'Create optimized multi-stage Dockerfiles for any language or framework'\n\n [View skill](<https://delaparra-services.nl/skills/multi-stage-dockerfile>) [Download zip](<https://delaparra-services.nl/skills/multi-stage-dockerfile/download>) \n- ### Docker Project Foundations\n\n \n\nUse this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database or cache dependency, or running services without host-level installs. Covers Dockerfile, compose.yaml, and .dockerignore creation with Docker best practices.\n\n [View skill](<https://delaparra-services.nl/skills/docker-project-foundations>) [Download zip](<https://delaparra-services.nl/skills/docker-project-foundations/download>)\n\n [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/multi-stage-build/skills.zip>)\n\n \n\n## Manuals\n\n \n\n- [Docker for your Laravel app](<https://delaparra-services.nl/manuals/docker-voor-je-laravel-app>)\n\n \n\n## Related services\n\n \n\n- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)\n\nPerhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.\n\n \n\n## Need any help?\n\n \n\nStuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.\n\n  [Get in touch](<https://delaparra-services.nl/availability>)\n\n[HTML version](https://delaparra-services.nl/knowledge-hub/multi-stage-build)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "FAQPage",
                "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#webpage",
                "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build",
                "name": "multi-stage build: Knowledge hub | DeLaParra Services",
                "description": "Using several FROM stages in one Dockerfile — build in a fat stage, then copy only the artefacts into a tiny final stage.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@type": "DefinedTerm",
                    "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#term",
                    "name": "multi-stage build",
                    "description": "Using several FROM stages in one Dockerfile — build in a fat stage, then copy only the artefacts into a tiny final stage.",
                    "termCode": "multi-stage-build",
                    "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build",
                    "inLanguage": "en",
                    "keywords": "Docker",
                    "dateModified": "2026-11-25T17:46:28+00:00",
                    "inDefinedTermSet": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#terms"
                    },
                    "isPartOf": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#dataset"
                    },
                    "subjectOf": [
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#webpage"
                        },
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#dataset"
                        }
                    ]
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#breadcrumb"
                },
                "mainEntity": [
                    {
                        "@type": "Question",
                        "name": "What is multi-stage build?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Using several FROM stages in one Dockerfile — build in a fat stage, then copy only the artefacts into a tiny final stage. A multi-stage Docker build uses several FROM instructions in one Dockerfile. Early stages contain the tools needed to build, such as Node, Composer or a compiler. The final stage copies in only the finished results."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "How is multi-stage build used in practice?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "The outcome is a much smaller production image without build tools, source maps or development dependencies. That means faster deploys and less for an attacker to work with."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What should you keep in mind with multi-stage build?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "A typical PHP setup has a stage that builds front-end assets with Node, one that installs Composer dependencies, and a final PHP image that copies both in. Name stages with AS and copy with COPY --from=assets. Each stage is cached separately, so changing PHP code does not rebuild the front-end assets, which keeps builds quick."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What does an example of multi-stage build look like?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "FROM golang:1.23 AS build WORKDIR /src COPY . . RUN go build -o app FROM gcr.io/distroless/base COPY --from=build /src/app /app ENTRYPOINT [\"/app\"]"
                        }
                    }
                ],
                "author": {
                    "@id": "https://delaparra-services.nl/#person"
                },
                "mentions": [
                    {
                        "@id": "https://delaparra-services.nl/skills/docker-build-strategies#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/multi-stage-dockerfile#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/docker-project-foundations#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/manuals/docker-voor-je-laravel-app#article"
                    }
                ]
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Knowledge hub",
                        "item": "https://delaparra-services.nl/knowledge-hub"
                    },
                    {
                        "@type": "ListItem",
                        "position": 3,
                        "name": "multi-stage build"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#dataset",
                "name": "multi-stage build",
                "description": "Using several FROM stages in one Dockerfile — build in a fat stage, then copy only the artefacts into a tiny final stage.",
                "url": "https://delaparra-services.nl/knowledge-hub/multi-stage-build",
                "identifier": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/multi-stage-build#term"
                },
                "creator": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://creativecommons.org/licenses/by/4.0/",
                "creditText": "Coders Lingo (https://coderslingo.com/resources/open-dataset/), CC BY 4.0",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "keywords": "Docker",
                "version": "2026-11-25",
                "dateModified": "2026-11-25T17:46:28+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#dataset",
                    "name": "IT terms from A to Z",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "multi-stage-build.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:28+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "multi-stage-build.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:28+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "multi-stage-build.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:28+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "multi-stage-build.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:28+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "multi-stage-build.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/multi-stage-build.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:28+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "multi-stage-build-skills.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/multi-stage-build/skills.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:28+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    }
                ]
            }
        ]
    }
}