Skip to content

Commit 57683dd

Browse files
committed
Update, install and clean in the same layer
for a significantly smaller image size. Before: ghcr.io/xcp-ng/xcp-ng-build-env 8.2 e985e704c252 10 minutes ago 1.03 GB ghcr.io/xcp-ng/xcp-ng-build-env 8.3 b557dcb6d541 11 minutes ago 1.14 GB ghcr.io/xcp-ng/xcp-ng-build-env 9.0 c738df7d5577 11 minutes ago 857 MB After: ghcr.io/xcp-ng/xcp-ng-build-env 8.2 a9a91fa03db8 7 seconds ago 491 MB ghcr.io/xcp-ng/xcp-ng-build-env 8.3 a36b1399ac01 About a minute ago 557 MB ghcr.io/xcp-ng/xcp-ng-build-env 9.0 78011dcbd6f3 11 minutes ago 708 MB Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent d49ff96 commit 57683dd

File tree

3 files changed

+43
-58
lines changed

3 files changed

+43
-58
lines changed

Dockerfile-7.x

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ ARG XCP_NG_BRANCH=7.6
1616
COPY files/xcp-ng.repo.7.x.in /etc/yum.repos.d/xcp-ng.repo
1717
RUN sed -i -e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" /etc/yum.repos.d/xcp-ng.repo
1818

19-
# Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
20-
RUN yum install -y yum-plugin-ovl
21-
22-
# Use priorities so that packages from our repositories are preferred over those from CentOS repositories
23-
RUN yum install -y yum-plugin-priorities
24-
2519
# Update
26-
RUN yum update -y
27-
28-
# Build requirements
29-
RUN yum install -y --exclude=gcc-xs \
20+
RUN yum update -y \
21+
# Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
22+
&& yum install -y yum-plugin-ovl \
23+
# Use priorities so that packages from our repositories are preferred over those from CentOS repositories
24+
&& yum install -y yum-plugin-priorities \
25+
# Build requirements
26+
&& yum install -y --exclude=gcc-xs \
3027
gcc \
3128
gcc-c++ \
3229
git \
@@ -38,16 +35,14 @@ RUN yum install -y --exclude=gcc-xs \
3835
rpm-python \
3936
sudo \
4037
yum-utils \
41-
epel-release
42-
43-
# Niceties
44-
RUN yum install -y \
38+
epel-release \
39+
# Niceties
40+
&& yum install -y \
4541
vim \
4642
wget \
47-
which
48-
49-
# clean package cache to avoid download errors
50-
RUN yum clean all
43+
which \
44+
# clean package cache to avoid download errors
45+
&& yum clean all
5146

5247
# OCaml in XS is slightly older than in CentOS
5348
RUN sed -i "/gpgkey/a exclude=ocaml*" /etc/yum.repos.d/Cent* /etc/yum.repos.d/epel*

Dockerfile-8.x

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ RUN sed -i -e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" /etc/yum.repos.d/xcp-ng
1919
# Install GPG key
2020
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
2121

22-
# Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
23-
# (still needed?)
24-
RUN yum install -y yum-plugin-ovl
25-
26-
# Use priorities so that packages from our repositories are preferred over those from CentOS repositories
27-
RUN yum install -y yum-plugin-priorities
28-
2922
# Update
30-
RUN yum update -y
31-
32-
# Common build requirements
33-
RUN yum install -y \
23+
RUN yum update -y \
24+
# Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
25+
# (still needed?)
26+
&& yum install -y yum-plugin-ovl \
27+
# Use priorities so that packages from our repositories are preferred over those from CentOS repositories
28+
&& yum install -y yum-plugin-priorities \
29+
# Common build requirements
30+
&& yum install -y \
3431
gcc \
3532
gcc-c++ \
3633
git \
@@ -41,16 +38,14 @@ RUN yum install -y \
4138
sudo \
4239
yum-utils \
4340
epel-release \
44-
epel-rpm-macros
45-
46-
# Niceties
47-
RUN yum install -y \
41+
epel-rpm-macros \
42+
# Niceties
43+
&& yum install -y \
4844
vim \
4945
wget \
50-
which
51-
52-
# clean package cache to avoid download errors
53-
RUN yum clean all
46+
which \
47+
# clean package cache to avoid download errors
48+
&& yum clean all
5449

5550
# OCaml in XS may be older than in CentOS
5651
RUN sed -i "/gpgkey/a exclude=ocaml*" /etc/yum.repos.d/Cent* /etc/yum.repos.d/epel*

Dockerfile-9.x

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ COPY files/Alma10-devel.repo /etc/yum.repos.d/
1010
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
1111

1212
# Update
13-
RUN dnf update -y
14-
15-
# Common build requirements
16-
RUN dnf install -y \
13+
RUN dnf update -y \
14+
# Common build requirements
15+
&& dnf install -y \
1716
gcc \
1817
gcc-c++ \
1918
git \
@@ -23,28 +22,24 @@ RUN dnf install -y \
2322
python3-rpm \
2423
sudo \
2524
dnf-plugins-core \
26-
epel-release
27-
28-
# EPEL: needs epel-release installed first
29-
RUN dnf install -y \
25+
epel-release \
26+
# EPEL: needs epel-release installed first
27+
&& dnf install -y \
3028
epel-rpm-macros \
31-
almalinux-git-utils
32-
33-
# Niceties
34-
RUN dnf install -y \
29+
almalinux-git-utils \
30+
# Niceties
31+
&& dnf install -y \
3532
bash-completion \
3633
vim \
3734
wget \
38-
which
39-
40-
# clean package cache to avoid download errors
41-
RUN yum clean all
42-
43-
# -release*, to be commented out to boostrap the build-env until it gets built
44-
# FIXME: isn't it already pulled as almalinux-release when available?
45-
RUN dnf install -y \
35+
which \
36+
# -release*, to be commented out to boostrap the build-env until it gets built
37+
# FIXME: isn't it already pulled as almalinux-release when available?
38+
&& dnf install -y \
4639
xcp-ng-release \
47-
xcp-ng-release-presets
40+
xcp-ng-release-presets \
41+
# clean package cache to avoid download errors
42+
&& yum clean all
4843
4944
# enable repositories commonly required to build
5045
RUN dnf config-manager --enable crb

0 commit comments

Comments
 (0)