El mié., 16 oct. 2019 a las 19:49, Julián Maestri (<serp...@gmail.com>) escribió:
> Example: > > # Stage 1: Load the project on an empty image, in this case this is a > development image (should change to use a minimal image) > > FROM basmalltalk/pharo:7.0-image AS loader > COPY load-project.st ./ > RUN pharo Pharo.image load-project.st --save --quit > > # Stage 2: Copy the resulting Pharo.image with our project loaded > # into a new docker image with just the vm > # start in a new stage to keep docker image minimal > FROM basmalltalk/pharo:7.0 > > USER root > > WORKDIR /opt/app > COPY start.sh . > COPY --from=loader /opt/pharo/Pharo.image ./ > COPY --from=loader /opt/pharo/Pharo.changes ./ > COPY --from=loader /opt/pharo/Pharo*.sources ./ > > RUN mkdir logs \ > && chmod a+x start.sh \ > && chown --recursive pharo:pharo /opt/app > > USER pharo > EXPOSE 8080 > > CMD ["./start.sh"] > > > The resulting image size is ~80mb including image, changes & sources > Reference: > https://docs.docker.com/develop/develop-images/multistage-build/ > > As a side note, the final image size is not what really matters, if you > have 20 different images all starting from the same base image (eg > ubuntu:18.04) the base layer is shared among all images so the network / > disk usage is less than the total size of the image. > > It's important to keep the docker image thin, but also to keep layers at a > minimum and not adding / removing stuff during the build, because those are > stored in the middle layers (multi stage helps to remove that). > > Cool!! Thank you Julián, Cheers, Hernán > Cheers. > > On Tue, 15 Oct 2019 at 20:00, Hernán Morales Durand < > hernan.mora...@gmail.com> wrote: > >> >> >> El lun., 14 oct. 2019 a las 5:23, Pierce Ng (<pie...@samadhiweb.com>) >> escribió: >> >>> On Mon, Oct 14, 2019 at 04:07:49AM -0300, Hernán Morales Durand wrote: >>> > Because I am lazy and want to avoid searching through all DockerHub >>> > repository pages... Do you know a Dockerfile to generate the smallest >>> > possible docker image for Pharo? >>> > Anyone could make it work Pharo on Alpine since it uses different libc? >>> >>> Hi Hernán, >>> >>> Please see following links: >>> >>> - https://github.com/pharo-contributions/Docker-Alpine >>> - https://hub.docker.com/r/pierceng/pharovm-alpine >>> - https://hub.docker.com/r/pierceng/pharo7-alpine >>> - https://www.samadhiweb.com/blog/2019.07.20.alpine.pharo.minimal.html >>> - https://www.samadhiweb.com/blog/2019.08.11.minimizing.pharo.html >>> >>> >> Nice! It works with latest minimal 7.0.4 too. >> >> BTW you used .sources whith seem to be for Pharo 7 >> (Pharo7.0-32bit-0903ade.sources), but when I tried with latest stable >> minimal and for some reason requires the V60 sources: >> >> $ docker run --rm --ulimit rtprio=2 pharo7_docker_alpine printVersion >> Pharo cannot locate the sources file named /pkg/image/PharoV60.sources. >> >> I found also another approach using rtprio=2:2 suggested from >> https://github.com/ba-st/docker-pharo/blob/master/docs/rtprio.md >> (soft:hard ulimits). >> >> The Alpine-based VM can be made smaller by removing unused/irrelevant >>> modules. >>> >>> Image-wise, currently I am using Pharo 7 minimal, which is just under >>> 30MB, and that forms the lower bound of the Pharo image size. >>> >>> >> The built image here is aprox. 99 Mbytes >> >> REPOSITORY TAG IMAGE ID CREATED >> SIZE >> pharo7_docker_alpine latest 595b9ece2625 3 hours >> ago 99.4MB >> >> but I think you didn't sumed the .sources. >> >> >>> However there is also the Pharo Candle effort that aims to make really >>> small images, which I hope to try out soon. >>> >>> > I am also interested in which stage you use to install packages into >>> the >>> > image, and why? Do you copy the contained image into docker already >>> built? >>> >>> For Pharo, I start with the regular or minimal image, then load my >>> packages. >>> >>> For Docker, I first build a container image for the VM only. Using that >>> I build a new container image from the Pharo image and other required >>> files. >>> >>> >> Thank you for sharing Pierce. >> >> Hernán >> >> >