Haskell and Docker a reasonable size of the expanded image?

I tried to create the Happstack PoC executable in Google App Engine using this Docker file:

FROM ubuntu:14.04 ENV APP_ROOT=/usr/share/app RUN apt-get update && apt-get install curl -y && curl -sSL https://get.haskellstack.org/ | sh COPY . ${APP_ROOT}/ WORKDIR ${APP_ROOT}/ RUN stack setup RUN stack build EXPOSE 8000 ENTRYPOINT ["stack","exec","app-exe"] 

It works, and I was able to deploy, but the resulting image seems huge.

I think the image is about 450 MB after installing stack , about 1.8 GB after stack setup and about 3 GB after stack build .

I think hundreds of MB seem reasonable, even up to GB. Is there any other approach I should take, perhaps extracting the resulting executable file to another image in some way to eliminate all unnecessary at runtime?

+5
source share
1 answer

This is the perfect solution for multi-stage docker assembly:

https://docs.docker.com/develop/develop-images/multistage-build/

You can apply the following:

 FROM ubuntu:14.04 as mybuild ENV APP_ROOT=/usr/share/app RUN apt-get update && apt-get install curl -y && curl -sSL https://get.haskellstack.org/ | sh COPY . ${APP_ROOT}/ WORKDIR ${APP_ROOT}/ RUN stack setup RUN stack build FROM ubuntu:14.04 COPY --from=mybuild /path/to/app-exe /dest/app-exe #edit this line accordingly EXPOSE 8000 ENTRYPOINT ["stack","exec","app-exe"] 

Everything until the second FROM not included in the final image, except that you copy using COPY --from .

+7
source

Source: https://habr.com/ru/post/1275832/


All Articles