Skip to content

Commit

Permalink
Reduce size of the final GSC image
Browse files Browse the repository at this point in the history
  • Loading branch information
amathew3 authored and Dmitrii Kuvaiskii committed Apr 26, 2023
1 parent f656037 commit c1413c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
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

0 comments on commit c1413c2

Please sign in to comment.