build: optimize apt-get cleanup during image build (#2558)

This commit is contained in:
Simon Becker 2023-09-30 02:04:58 +02:00 committed by GitHub
parent 40ab328bb9
commit a331042e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,6 +54,7 @@ RUN apt-get update \
# LDAP Dependencies # LDAP Dependencies
libsasl2-dev libldap2-dev libssl-dev \ libsasl2-dev libldap2-dev libssl-dev \
gnupg gnupg2 gnupg1 \ gnupg gnupg2 gnupg1 \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -U --no-cache-dir pip && pip install -U --no-cache-dir pip
# install poetry - respects $POETRY_VERSION & $POETRY_HOME # install poetry - respects $POETRY_VERSION & $POETRY_HOME
@ -92,19 +93,18 @@ RUN apt-get update \
curl \ curl \
gnupg \ gnupg \
libldap-common \ libldap-common \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \ RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs && apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Add Yarn # Add Yarn
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null \ RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list \ && echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update && apt-get install yarn && apt-get update \
&& apt-get install yarn \
# Clean apt && rm -rf /var/lib/apt/lists/*
RUN apt-get autoremove && rm -rf /var/lib/apt/lists/*
# copying poetry and venv into image # copying poetry and venv into image
COPY --from=builder-base $POETRY_HOME $POETRY_HOME COPY --from=builder-base $POETRY_HOME $POETRY_HOME