Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 859e460

Browse files
docker: limit number of layers in each image
do all updates and packages installs in one RUN; and create user and password in one step as well.
1 parent 9beab39 commit 859e460

7 files changed

Lines changed: 57 additions & 73 deletions

utils/docker/images/Dockerfile.archlinux-base-latest

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ ARG MISC_DEPS="\
7676
whois"
7777

7878
# Update the Apt cache and install basic tools
79-
RUN pacman -Syu --noconfirm
80-
RUN pacman -S --noconfirm \
79+
RUN pacman -Syu --noconfirm \
80+
&& pacman -S --noconfirm \
8181
${BASE_DEPS} \
8282
${LIBPMEMOBJ_CPP_DEPS} \
8383
${NDCTL_DEPS} \
@@ -86,7 +86,8 @@ RUN pacman -S --noconfirm \
8686
${EXAMPLES_DEPS} \
8787
${DOC_DEPS} \
8888
${TESTS_DEPS} \
89-
${MISC_DEPS}
89+
${MISC_DEPS} \
90+
&& rm -rf /var/cache/pacman/pkg/*
9091

9192
# Install libndctl
9293
COPY install-libndctl.sh install-libndctl.sh
@@ -104,14 +105,11 @@ RUN ./install-pmdk.sh
104105
ENV USER user
105106
ENV USERPASS p1a2s3s4
106107
ENV PFILE ./password
107-
RUN useradd -m $USER
108-
RUN echo $USERPASS > $PFILE
109-
RUN echo $USERPASS >> $PFILE
110-
RUN passwd $USER < $PFILE
111-
RUN rm -f $PFILE
112-
RUN sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
113-
RUN gpasswd wheel -a $USER
108+
RUN useradd -m $USER \
109+
&& echo $USERPASS > $PFILE \
110+
&& echo $USERPASS >> $PFILE \
111+
&& passwd $USER < $PFILE \
112+
&& rm -f $PFILE \
113+
&& sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers \
114+
&& gpasswd wheel -a $USER
114115
USER $USER
115-
116-
# Clean the cache of packages
117-
RUN rm -rf /var/cache/pacman/pkg/*

utils/docker/images/Dockerfile.centos-8

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,12 @@ ARG MISC_DEPS="\
7474
pkgconf \
7575
sudo"
7676

77-
# Update package repository and extend dnf's package base
78-
RUN dnf update -y
79-
RUN dnf install -y epel-release
80-
RUN dnf install -y 'dnf-command(config-manager)'
81-
RUN dnf config-manager --set-enabled powertools
82-
83-
# Install basic tools
77+
# Update package repository, extend dnf's package base and install basic tools
8478
RUN dnf update -y \
79+
&& dnf install -y epel-release \
80+
&& dnf install -y 'dnf-command(config-manager)' \
81+
&& dnf config-manager --set-enabled powertools \
82+
&& dnf update -y \
8583
&& dnf install -y \
8684
${BASE_DEPS} \
8785
${LIBPMEMOBJ_CPP_DEPS} \
@@ -104,7 +102,7 @@ RUN ./install-pmdk.sh rpm
104102
# Add user
105103
ENV USER user
106104
ENV USERPASS pass
107-
RUN useradd -m $USER
108-
RUN echo $USERPASS | passwd $USER --stdin
109-
RUN gpasswd wheel -a $USER
105+
RUN useradd -m $USER \
106+
&& echo $USERPASS | passwd $USER --stdin \
107+
&& gpasswd wheel -a $USER
110108
USER $USER

utils/docker/images/Dockerfile.fedora-32

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ RUN ./install-pmdk.sh rpm
9999
# Add user
100100
ENV USER user
101101
ENV USERPASS pass
102-
RUN useradd -m $USER
103-
RUN echo "$USER:$USERPASS" | chpasswd
104-
RUN gpasswd wheel -a $USER
102+
RUN useradd -m $USER \
103+
&& echo "$USER:$USERPASS" | chpasswd \
104+
&& gpasswd wheel -a $USER
105105
USER $USER

utils/docker/images/Dockerfile.fedora-33

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ RUN ./install-pmdk.sh rpm
9898
# Add user
9999
ENV USER user
100100
ENV USERPASS pass
101-
RUN useradd -m $USER
102-
RUN echo "$USER:$USERPASS" | chpasswd
103-
RUN gpasswd wheel -a $USER
101+
RUN useradd -m $USER \
102+
&& echo "$USER:$USERPASS" | chpasswd \
103+
&& gpasswd wheel -a $USER
104104
USER $USER

utils/docker/images/Dockerfile.fedora-rawhide

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ RUN dnf update -y \
6969
# Add user
7070
ENV USER user
7171
ENV USERPASS pass
72-
RUN useradd -m $USER
73-
RUN echo "$USER:$USERPASS" | chpasswd
74-
RUN gpasswd wheel -a $USER
72+
RUN useradd -m $USER \
73+
&& echo "$USER:$USERPASS" | chpasswd \
74+
&& gpasswd wheel -a $USER
7575
USER $USER

utils/docker/images/Dockerfile.opensuse-leap-latest

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,21 @@ ARG MISC_DEPS="\
7171
pkg-config \
7272
sudo"
7373

74-
# Update the OS
75-
RUN zypper dup -y
76-
77-
# Update all packages
78-
RUN zypper update -y
79-
80-
# Install basic tools
81-
RUN zypper install -y \
74+
# Update the OS, packages and install basic tools
75+
RUN zypper dup -y \
76+
&& zypper update -y \
77+
&& zypper install -y \
8278
${BASE_DEPS} \
8379
${LIBPMEMOBJ_CPP_DEPS} \
8480
${PMDK_DEPS} \
8581
${VALGRIND_DEPS} \
8682
${EXAMPLES_DEPS} \
8783
${DOC_DEPS} \
8884
${TESTS_DEPS} \
89-
${MISC_DEPS}
90-
91-
# Clean the package cache
92-
RUN zypper clean all
85+
${MISC_DEPS} \
86+
&& zypper clean all
9387

94-
# Install valgrind
88+
# Install valgrind and update pkg-config path variable
9589
COPY install-valgrind.sh install-valgrind.sh
9690
RUN ./install-valgrind.sh
9791
ENV PKG_CONFIG_PATH $PKG_CONFIG_PATH:/usr/lib/pkgconfig/
@@ -104,12 +98,12 @@ RUN ./install-pmdk.sh rpm
10498
ENV USER user
10599
ENV USERPASS p1a2s3s4
106100
ENV PFILE ./password
107-
RUN useradd -m $USER
108-
RUN echo $USERPASS > $PFILE
109-
RUN echo $USERPASS >> $PFILE
110-
RUN passwd $USER < $PFILE
111-
RUN rm -f $PFILE
112-
RUN sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
113-
RUN groupadd wheel
114-
RUN gpasswd wheel -a $USER
101+
RUN useradd -m $USER \
102+
&& echo $USERPASS > $PFILE \
103+
&& echo $USERPASS >> $PFILE \
104+
&& passwd $USER < $PFILE \
105+
&& rm -f $PFILE \
106+
&& sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers \
107+
&& groupadd wheel \
108+
&& gpasswd wheel -a $USER
115109
USER $USER

utils/docker/images/Dockerfile.opensuse-tumbleweed-latest

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,19 @@ ARG MISC_DEPS="\
7171
pkg-config \
7272
sudo"
7373

74-
# Update the OS
75-
RUN zypper dup -y
76-
77-
# Update all packages
78-
RUN zypper update -y
79-
80-
# Install basic tools
81-
RUN zypper install -y \
74+
# Update the OS, packages and install basic tools
75+
RUN zypper dup -y \
76+
&& zypper update -y \
77+
&& zypper install -y \
8278
${BASE_DEPS} \
8379
${LIBPMEMOBJ_CPP_DEPS} \
8480
${PMDK_DEPS} \
8581
${VALGRIND_DEPS} \
8682
${EXAMPLES_DEPS} \
8783
${DOC_DEPS} \
8884
${TESTS_DEPS} \
89-
${MISC_DEPS}
90-
91-
# Clean the package cache
92-
RUN zypper clean all
85+
${MISC_DEPS} \
86+
&& zypper clean all
9387

9488
# Install valgrind
9589
COPY install-valgrind.sh install-valgrind.sh
@@ -104,12 +98,12 @@ RUN ./install-pmdk.sh rpm
10498
ENV USER user
10599
ENV USERPASS p1a2s3s4
106100
ENV PFILE ./password
107-
RUN useradd -m $USER
108-
RUN echo $USERPASS > $PFILE
109-
RUN echo $USERPASS >> $PFILE
110-
RUN passwd $USER < $PFILE
111-
RUN rm -f $PFILE
112-
RUN sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
113-
RUN groupadd wheel
114-
RUN gpasswd wheel -a $USER
101+
RUN useradd -m $USER \
102+
&& echo $USERPASS > $PFILE \
103+
&& echo $USERPASS >> $PFILE \
104+
&& passwd $USER < $PFILE \
105+
&& rm -f $PFILE \
106+
&& sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers \
107+
&& groupadd wheel \
108+
&& gpasswd wheel -a $USER
115109
USER $USER

0 commit comments

Comments
 (0)