-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathContainerfile.minimal
69 lines (66 loc) · 3.32 KB
/
Containerfile.minimal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
ARG SYSBASE=almalinux:9
FROM ${SYSBASE} as system-build
RUN mkdir /mnt/sys-root; \
dnf install -y \
--installroot /mnt/sys-root \
--releasever 9 \
--setopt install_weak_deps=false \
--nodocs \
almalinux-release \
bash \
coreutils-single \
curl-minimal \
glibc-minimal-langpack \
libcurl-minimal \
libusbx \
microdnf \
rootfiles \
; \
echo '%_install_langs en_US.UTF-8' > /etc/rpm/macros.image-language-conf ;\
dnf reinstall -y \
--installroot /mnt/sys-root \
--releasever 9 \
--setopt install_weak_deps=false \
--nodocs \
krb5-libs ; \
dnf --installroot /mnt/sys-root clean all;
# Additional hacks for kickstart file and backward compatable support
RUN rm -rf /mnt/sys-root/var/log/dnf* /mnt/sys-root/var/log/yum.* /mnt/sys-root/var/cache/dnf /mnt/sys-root/var/lib/dnf/repos; \
rm -rf /mnt/sys-root/var/lib/dnf/history* /mnt/sys-root/var/log/hawkey.log /mnt/sys-root/boot /mnt/sys-root/dev/null /mnt/sys-root/run/*; \
mkdir -p /mnt/sys-root/run/lock; \
# generate build time file for compatibility with CentOS
/bin/date +%Y%m%d_%H%M > /mnt/sys-root/etc/BUILDTIME; \
echo '%_install_langs C.utf8' > /mnt/sys-root/etc/rpm/macros.image-language-conf; \
echo 'LANG="C.utf8"' > /mnt/sys-root/etc/locale.conf; \
echo 'container' > /mnt/sys-root/etc/dnf/vars/infra; \
touch /mnt/sys-root/etc/.pwd.lock; \
chmod 600 /mnt/sys-root/etc/.pwd.lock; \
echo '0.0 0 0.0' > /mnt/sys-root/etc/adjtime; \
echo '0' >> /mnt/sys-root/etc/adjtime; \
echo 'UTC' >> /mnt/sys-root/etc/adjtime; \
echo '# This file has been generated by the Anaconda Installer.' > /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;\
echo '# Allow root to log in using ssh. Remove this file to opt-out.' >> /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;\
echo 'PERMITROOTLOGIN="-oPermitRootLogin=yes"' >> /mnt/sys-root/etc/sysconfig/sshd-permitrootlogin ;\
echo 'KEYMAP="us"' > /mnt/sys-root/etc/vconsole.conf; \
echo 'FONT="eurlatgr"' >> /mnt/sys-root/etc/vconsole.conf; \
# /mnt/sys-root/usr/share/locale/en@* /mnt/sys-root/usr/share/locale/en /mnt/sys-root/usr/share/locale/en*@*
rm -rf /mnt/sys-root/usr/share/locale/en_CA/ /mnt/sys-root/usr/share/locale/en_GB/ /mnt/sys-root/usr/share/i18n/charmaps /mnt/sys-root/usr/share/i18n/locales ;\
rm -f /mnt/sys-root/etc/machine-id; \
touch /mnt/sys-root/etc/machine-id; \
touch /mnt/sys-root/etc/resolv.conf; \
touch /mnt/sys-root/etc/hostname; \
mkdir -p /mnt/sys-root/var/cache/private /mnt/sys-root/var/lib/private /mnt/sys-root/var/lib/systemd/coredump ;\
chmod 700 /mnt/sys-root/var/cache/private ; \
chmod 700 /mnt/sys-root/var/lib/private ; \
groupadd -R '/mnt/sys-root/' -r -p '!*' -g 996 sgx && groupadd -R '/mnt/sys-root/' -r -p '!*' -g 995 systemd-oom ; \
useradd -R '/mnt/sys-root/' -r -c 'systemd Userspace OOM Killer' -g 995 -u 995 -s '/usr/sbin/nologin' -M -d '/' systemd-oom ; \
sed -i "/sgx/d" /mnt/sys-root/etc/group- ; \
sed -i "/sgx/d" /mnt/sys-root/etc/gshadow- ; \
cd /mnt/sys-root/etc ; \
ln -s ../usr/share/zoneinfo/UTC localtime ; \
cd /mnt/sys-root/etc/systemd/system ; \
ln -s /usr/lib/systemd/system/multi-user.target default.target
# Almalinux minimal build
FROM scratch
COPY --from=system-build /mnt/sys-root/ /
CMD ["/bin/bash"]