Speed up Docker image build and make image smaller

Run `apt-get upgrade` right after `apt-get install`, instead of cleaning
up apt index first, do `apt-get update` again, then `apt-get upgrade`.

This will save some build time and disk space, because it didn't clean
up apt index after the `apt-get upgrade` before.
This commit is contained in:
Peter Dave Hello 2023-05-19 22:01:23 +08:00
parent 9f1417f28c
commit 6c5f27d7f1
2 changed files with 2 additions and 4 deletions

View file

@ -5,11 +5,10 @@ WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get -qqq install --no-install-recommends -y pkg-config gcc g++ \
&& apt-get upgrade --assume-yes \
&& apt-get clean \
&& rm -rf /var/lib/apt
RUN apt-get update && apt-get upgrade --assume-yes
RUN python -mvenv venv && ./venv/bin/pip install --upgrade pip
COPY . .

View file

@ -9,11 +9,10 @@ WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get -qqq install --no-install-recommends -y libicu-dev libaspell-dev libcairo2 libcairo2-dev pkg-config gcc g++ python3.8-dev python3-pip libpython3.8-dev\
&& apt-get upgrade --assume-yes \
&& apt-get clean \
&& rm -rf /var/lib/apt
RUN apt-get update && apt-get upgrade --assume-yes
RUN pip3 install --upgrade pip && apt-get remove python3-pip --assume-yes
RUN ln -s /usr/bin/python3 /usr/bin/python