Trimmed down Dockerfile by removing caches

This commit is contained in:
squidfunk 2021-02-27 10:11:35 +01:00
parent 88437e4e36
commit bf775ecc1e

View File

@ -23,8 +23,9 @@ FROM python:3.8.7-alpine3.12
# Build-time flags # Build-time flags
ARG WITH_PLUGINS=true ARG WITH_PLUGINS=true
# Packages directory # Environment variables
ENV PACKAGES=/usr/local/lib/python3.8/site-packages ENV PACKAGES=/usr/local/lib/python3.8/site-packages
ENV PYTHONDONTWRITEBYTECODE=1
# Set build directory # Set build directory
WORKDIR /tmp WORKDIR /tmp
@ -37,7 +38,7 @@ COPY README.md README.md
COPY requirements.txt requirements.txt COPY requirements.txt requirements.txt
COPY setup.py setup.py COPY setup.py setup.py
# Perform build and cleanup artifacts # Perform build and cleanup artifacts and caches
RUN \ RUN \
apk add --no-cache \ apk add --no-cache \
git \ git \
@ -48,8 +49,8 @@ RUN \
&& \ && \
if [ "${WITH_PLUGINS}" = "true" ]; then \ if [ "${WITH_PLUGINS}" = "true" ]; then \
pip install --no-cache-dir \ pip install --no-cache-dir \
'mkdocs-minify-plugin>=0.3' \ "mkdocs-minify-plugin>=0.3" \
'mkdocs-redirects>=1.0'; \ "mkdocs-redirects>=1.0"; \
fi \ fi \
&& apk del .build gcc musl-dev \ && apk del .build gcc musl-dev \
&& \ && \
@ -59,7 +60,12 @@ RUN \
${PACKAGES}/material \ ${PACKAGES}/material \
${PACKAGES}/mkdocs/themes/$theme; \ ${PACKAGES}/mkdocs/themes/$theme; \
done \ done \
&& rm -rf /tmp/* && rm -rf /tmp/* /root/.cache \
&& \
find ${PACKAGES} \
-type f \
-path "*/__pycache__/*" \
-exec rm -f {} \;
# Set working directory # Set working directory
WORKDIR /docs WORKDIR /docs