You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 22, 2023. It is now read-only.
Repository navigation
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
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.
Yes, multi-stage builds are definitely the future of Minimeteor. I'd actually be really glad not having to support two different build mechanisms. :)
What I can't really figure out yet is how to select base images dynamically. I want to specify mhart/alpine-node:x.x based on the output of meteor build, since it specifies the Node version required to run the bundle. What you suggested above would work, but it would also require the user to update the Dockerfile every time the Meteor version is upgraded. Still, that would probably be a good start.
I'm still lamenting about this. Any suggestions are welcome.
True, that would be much nicer.
I could only imagine to take a plain alpine, COPY --from from the meteor build-image and install the corresponding node version ONBUILD. But - for me - it's not worth the increased build-time. We build our apps every few hours and update meteor just every few weeks ...
Now that I think about it - I guess, we could hide all three steps inside one image. So my example above could be stripped down to one statement:
FROM aedm/minimeteor:1.5.2 # debian, alpine-node with build-deps and finally: alpine-node minimal
Activity
aedm commentedon Sep 12, 2017
Yes, multi-stage builds are definitely the future of Minimeteor. I'd actually be really glad not having to support two different build mechanisms. :)
What I can't really figure out yet is how to select base images dynamically. I want to specify
mhart/alpine-node:x.xbased on the output ofmeteor build, since it specifies the Node version required to run the bundle. What you suggested above would work, but it would also require the user to update the Dockerfile every time the Meteor version is upgraded. Still, that would probably be a good start.I'm still lamenting about this. Any suggestions are welcome.
csillag commentedon Sep 12, 2017
That would be awesome.
sokki commentedon Sep 12, 2017
True, that would be much nicer.
I could only imagine to take a plain
alpine,COPY --fromfrom themeteor build-image and install the corresponding node versionONBUILD. But - for me - it's not worth the increased build-time. We build our apps every few hours and update meteor just every few weeks ...Now that I think about it - I guess, we could hide all three steps inside one image. So my example above could be stripped down to one statement: