Hi Guillaume,
I have also tested this trick and it is reducing the size of the image upto a good extent.
With non multi-stage docker file the size of the image is around 7.57GB
And with multi-stage docker file the size is 3.77GB. Nice !
But when I inspect the image the architecture of the image is changing from amd to arm.
Here is my docker file :
ARG IMAGE=containers.intersystems.com/intersystems/irishealth:2023.3
FROM --platform=linux/amd64 $IMAGE as builder
# as builder
USER root
RUN mkdir -p /ocie/install
RUN chmod -R 777 /ocie
RUN chown -R irisowner:irisowner /ocie
USER irisowner
COPY --chown=irisowner:irisowner install_app.sh /ocie/tmp/install_app.sh
COPY --chown=irisowner:irisowner AppServer.cls /ocie/install/AppServer.cls
RUN chmod +x /ocie/tmp/install_app.sh
RUN mkdir -p /ocie/scripts
RUN chmod -R 777 /usr/irissys/mgr
# run iris and initial
RUN iris start IRIS \
&& /ocie/tmp/install_app.sh "iris" "localhost" "52773" "/usr/irissys" "/usr/irissys" "DEV"\
&& iris stop IRIS quietly
# # copy data from builder
FROM $IMAGE as final
ADD --chown=${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} https://github.com/grongierisc/iris-docker-multi-stage-script/releases/l... /irisdev/app/copy-data.py
RUN --mount=type=bind,source=/,target=/builder/root,from=builder \
cp -f /builder/root/usr/irissys/iris.cpf /usr/irissys/iris.cpf && \
python3 /irisdev/app/copy-data.py -c /usr/irissys/iris.cpf -d /builder/root/
without multi-stage docker file :
docker inspect <imageid>
"Architecture": "amd64",
with multi-stage docker file:
"Architecture": "arm64",