Skip to content

Commit

Permalink
perf: Lower images sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Oct 25, 2024
1 parent 650810a commit a256ad1
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 20 deletions.
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-bookworm
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,19 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked --mount=target=/
zlib1g-dev \
&& curl -LsSf --retry 8 --retry-all-errors https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,19 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked --mount=target=/
zlib1g-dev \
&& curl -LsSf --retry 8 --retry-all-errors https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-focal
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked --mount=target=/
zlib1g-dev \
&& curl -LsSf --retry 8 https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-jammy
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked --mount=target=/
zlib1g-dev \
&& curl -LsSf --retry 8 --retry-all-errors https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-noble
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,19 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked --mount=target=/
zlib1g-dev \
&& curl -LsSf --retry 8 --retry-all-errors https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ RUN --mount=target=/var/cache/yum,type=cache,sharing=locked \
zlib-devel \
&& curl -LsSf --retry 8 https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
7 changes: 5 additions & 2 deletions src/docker/Dockerfile-ubi9
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,19 @@ RUN --mount=target=/var/cache/yum,type=cache,sharing=locked \
zlib-devel \
&& curl -LsSf --retry 8 --retry-all-errors https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o python.tgz \
&& tar -xzf python.tgz \
&& rm python.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
--enable-optimizations \
--with-ensurepip=install \
--with-lto \
&& make -j$(nproc) \
&& make install \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& python3 --version \
&& python3 -m pip --version
&& python3 -m pip --version \
&& find / -depth -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null

FROM base

Expand Down
11 changes: 8 additions & 3 deletions src/docker/Dockerfile-win-ltsc2019
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ ARG PYTHON_VERSION
ENV PYTHON_VERSION=${PYTHON_VERSION}
RUN curl -LsSf --retry 8 --retry-all-errors "https://python.org/ftp/python/${Env:PYTHON_VERSION}/python-${Env:PYTHON_VERSION}-amd64.exe" -o python.exe \
&& Start-Process python.exe -Wait -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1 Include_test=0' \
&& Remove-Item python.exe
&& Remove-Item python.exe \
&& Get-ChildItem 'C:\\' -Include '__pycache__' -Recurse -Force | Remove-Item -Recurse -Force

# Install Python build tools
RUN python --version \
&& python -m pip \
--disable-pip-version-check \
--no-cache-dir \
--quiet \
install \
setuptools wheel
setuptools wheel \
&& Get-ChildItem 'C:\\' -Include '__pycache__' -Recurse -Force | Remove-Item -Recurse -Force

# Install Azure CLI, then verify installation
ARG AZURE_CLI_VERSION
Expand All @@ -57,7 +61,8 @@ RUN python -m pip \
--quiet \
install \
"azure-cli==${Env:AZURE_CLI_VERSION}" \
&& az version
&& az version \
&& Get-ChildItem 'C:\\' -Include '__pycache__' -Recurse -Force | Remove-Item -Recurse -Force

# Install AWS CLI, then verify installation
ARG AWS_CLI_VERSION
Expand Down
11 changes: 8 additions & 3 deletions src/docker/Dockerfile-win-ltsc2022
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ ARG PYTHON_VERSION
ENV PYTHON_VERSION=${PYTHON_VERSION}
RUN curl -LsSf --retry 8 --retry-all-errors "https://python.org/ftp/python/${Env:PYTHON_VERSION}/python-${Env:PYTHON_VERSION}-amd64.exe" -o python.exe \
&& Start-Process python.exe -Wait -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1 Include_test=0' \
&& Remove-Item python.exe
&& Remove-Item python.exe \
&& Get-ChildItem 'C:\\' -Include '__pycache__' -Recurse -Force | Remove-Item -Recurse -Force

# Install Python build tools
RUN python --version \
&& python -m pip \
--disable-pip-version-check \
--no-cache-dir \
--quiet \
install \
setuptools wheel
setuptools wheel \
&& Get-ChildItem 'C:\\' -Include '__pycache__' -Recurse -Force | Remove-Item -Recurse -Force

# Install Azure CLI, then verify installation
ARG AZURE_CLI_VERSION
Expand All @@ -57,7 +61,8 @@ RUN python -m pip \
--quiet \
install \
"azure-cli==${Env:AZURE_CLI_VERSION}" \
&& az version
&& az version \
&& Get-ChildItem 'C:\\' -Include '__pycache__' -Recurse -Force | Remove-Item -Recurse -Force

# Install AWS CLI, then verify installation
ARG AWS_CLI_VERSION
Expand Down

0 comments on commit a256ad1

Please sign in to comment.