1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-12-21 15:18:51 -05:00

Reduce final image size by 92%

By performing the build in one image (with all the needed tools)
and then copying over the result files into an image based on
stock nginx, the image size is reduced from 1.4 GB to 111 MB.
This commit is contained in:
Jonas Schäfer 2019-10-03 21:01:18 +02:00
parent 5ca03340b4
commit 735b17dcc7

View File

@ -1,7 +1,7 @@
# Builds all XEPs by default, HTML & PDF # Builds all XEPs by default, HTML & PDF
# docker build . --build-arg NCORES=X --build-arg TARGETS="html pdf" # docker build . --build-arg NCORES=X --build-arg TARGETS="html pdf"
# from Dockerfile.base # from Dockerfile.base
FROM xmppxsf/xeps-base:latest FROM xmppxsf/xeps-base:latest as build
ARG NCORES=1 ARG NCORES=1
ARG TARGETS="html inbox-html inbox-xml pdf xeplist refs xml" ARG TARGETS="html inbox-html inbox-xml pdf xeplist refs xml"
@ -14,7 +14,10 @@ COPY texml-xsl/*.xsl /src/texml-xsl/
WORKDIR /src WORKDIR /src
RUN OUTDIR=/var/www/html/extensions/ make -j$NCORES $TARGETS RUN OUTDIR=/var/www/html/extensions/ make -j$NCORES $TARGETS
RUN bash -c 'rm -f /var/www/html/extensions/*.{log,aux,toc,tex,tex.xml,out}'
FROM nginx:1-alpine
RUN mkdir /usr/share/nginx/html/extensions/
COPY --from=build /var/www/html/extensions/ /usr/share/nginx/html/extensions/
RUN sed -ri '/root\s+\/usr\/share\/nginx\/html/s/^(.+)$/\1\nautoindex on;/' /etc/nginx/conf.d/default.conf
EXPOSE 80 EXPOSE 80
CMD /usr/sbin/nginx -g 'daemon off;'