Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.
This repository was archived by the owner on May 22, 2023. It is now read-only.

Use multi-stage builds to reduce build-time and image-size #25

@sokki

Description

@sokki

I guess, we could combine the advantages of both methods script and Dockerfile.

Multi-stage builds are a new feature in Docker 17.05. With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image.
https://docs.docker.com/engine/userguide/eng-image/multistage-build/

An applications Dockerfile might look like

FROM aedm/minimeteor:1.5.2-build # debian and alpine-node with build-deps
FROM aedm/minimeteor:1.5.2-production # alpine-node minimal
COPY --from=0 /bundle .

This way, we would not need to install dependencies and meteor on every build and still have a minimal-weight image in the end 🙃

I have not tried out how to combine the new COPY --from and ONBUILD though. But I hope, that works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions