Reduce image size by clearing caches
With these changess, we build a 40% lighter image. First, we regroup all apt install lines, so we can remove cache on the same layer. Then we remove pip3 cache, which is absolutely not negligible.
This commit is contained in:
parent
a59cc4fe19
commit
9c91017c01
|
@ -1,13 +1,18 @@
|
|||
FROM ubuntu:22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt-get update
|
||||
RUN apt-get install ca-certificates -y
|
||||
|
||||
RUN apt update \
|
||||
&& apt install ca-certificates python3 python3-pip php8.1-cli php8.1-xml -y --no-install-recommends \
|
||||
&& apt clean -yq \
|
||||
&& apt autoremove -yq \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
|
||||
&& truncate -s 0 /var/log/*log
|
||||
|
||||
RUN update-ca-certificates
|
||||
RUN apt-get install python3 python3-pip -y
|
||||
RUN apt-get install php8.1-cli php8.1-xml -y --no-install-recommends
|
||||
RUN python3 -c "import sys; print(sys.version)"
|
||||
RUN python3 -m pip install --upgrade pip
|
||||
RUN pip3 install -U setuptools
|
||||
RUN pip3 install -U setuptools --no-cache-dir
|
||||
RUN mkdir /usr/src/app
|
||||
|
||||
ENV LANG en_US.UTF-8
|
||||
|
@ -18,5 +23,5 @@ WORKDIR /usr/src/app
|
|||
|
||||
COPY . .
|
||||
|
||||
RUN pip3 install .[test]
|
||||
RUN pip3 install .[test] --no-cache-dir
|
||||
CMD ["pytest"]
|
||||
|
|
Loading…
Reference in New Issue