Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSC image size optimizations #141

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions templates/centos/Dockerfile.build.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* &&\
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* &&\
sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-Linux-PowerTools.repo

# Combine all installation and removal steps in a single RUN command to reduce the final image size.
# This is because each Dockerfile command creates a new layer which necessarily adds size to the
# final image. This trick allows to decrease the image size by hundreds of MBs.
RUN dnf update -y \
&& dnf install -y \
binutils \
Expand All @@ -17,13 +20,13 @@ RUN dnf update -y \
python3-pip \
python3-protobuf \
&& /usr/bin/python3 -B -m pip install click jinja2 protobuf \
'tomli>=1.1.0' 'tomli-w>=0.4.0'

'tomli>=1.1.0' 'tomli-w>=0.4.0' \
&& dnf repolist \
# For compatibility with Gramine v1.3 or lower
RUN /usr/bin/python3 -B -m pip install 'toml>=0.10'

&& /usr/bin/python3 -B -m pip install 'toml>=0.10' \
# Install pyelftools after the installation of epel-release as it is provided by the EPEL repo
RUN dnf install -y python3-pyelftools
&& dnf install -y python3-pyelftools \
&& dnf -y clean all

{% if buildtype != "release" %}
RUN dnf install -y \
Expand Down
16 changes: 11 additions & 5 deletions templates/debian/Dockerfile.build.template
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
{% extends "Dockerfile.common.build.template" %}

{% block install %}
# Combine all installation and removal steps in a single RUN command to reduce the final image size.
# This is because each Dockerfile command creates a new layer which necessarily adds size to the
# final image. This trick allows to decrease the image size by hundreds of MBs.
RUN apt-get update \
&& env DEBIAN_FRONTEND=noninteractive apt-get install -y \
binutils \
expect \
libcurl4-openssl-dev \
libprotobuf-c-dev \
locales \
locales-all \
openssl \
python3 \
python3-cryptography \
python3-pip \
python3-protobuf \
python3-pyelftools \
&& /usr/bin/python3 -B -m pip install click jinja2 protobuf \
'tomli>=1.1.0' 'tomli-w>=0.4.0'

'tomli>=1.1.0' 'tomli-w>=0.4.0' \
# For compatibility with Gramine v1.3 or lower
RUN /usr/bin/python3 -B -m pip install 'toml>=0.10'
&& /usr/bin/python3 -B -m pip install 'toml>=0.10' \
# Since all needed pip packages are installed, we can uninstall python3-pip safely
&& apt-get remove -y python3-pip \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

{% if buildtype != "release" %}
RUN env DEBIAN_FRONTEND=noninteractive apt-get install -y \
RUN apt-get update \
&& env DEBIAN_FRONTEND=noninteractive apt-get install -y \
gdb \
less \
libunwind8 \
Expand Down