Docker setup

# 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
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).
Cheers.
Julian Maestri
%d bloggers like this: