mirror of
https://github.com/linka-cloud/d2vm.git
synced 2026-05-12 18:38:15 +00:00
e77827df6c
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
68 lines
1.9 KiB
Docker
68 lines
1.9 KiB
Docker
FROM {{ .Image }} AS rootfs
|
|
|
|
USER root
|
|
|
|
{{ if and (eq .Release.ID "centos") (le (atoi .Release.VersionID) 8) }}
|
|
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \
|
|
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
|
|
{{ end }}
|
|
|
|
# See https://bugzilla.redhat.com/show_bug.cgi?id=1917213
|
|
RUN yum install -y \
|
|
kernel \
|
|
systemd \
|
|
NetworkManager \
|
|
e2fsprogs \
|
|
sudo && \
|
|
systemctl enable NetworkManager && \
|
|
systemctl unmask systemd-remount-fs.service && \
|
|
systemctl unmask getty.target && \
|
|
mkdir -p /boot && \
|
|
find /boot -type l -exec rm {} \;
|
|
|
|
{{- if .GrubBIOS }}
|
|
RUN yum install -y grub2
|
|
{{- end }}
|
|
{{- if .GrubEFI }}
|
|
RUN yum install -y grub2 grub2-efi-x64 grub2-efi-x64-modules
|
|
{{- end }}
|
|
|
|
{{ if .Luks }}
|
|
RUN yum install -y cryptsetup && \
|
|
dracut --no-hostonly --regenerate-all --force --install="/usr/sbin/cryptsetup"
|
|
{{ else }}
|
|
RUN dracut --no-hostonly --regenerate-all --force
|
|
{{ end }}
|
|
|
|
{{ if .Password }}RUN echo "root:{{ .Password }}" | chpasswd {{ end }}
|
|
|
|
{{- if .Grub }}
|
|
RUN set -e; \
|
|
for linux in /usr/lib/modules/*/vmlinuz; do \
|
|
[ -e "$linux" ] || continue; \
|
|
kver="$(basename "$(dirname "$linux")")"; \
|
|
cp "/usr/lib/modules/${kver}/vmlinuz" "/boot/vmlinuz-${kver}"; \
|
|
done
|
|
RUN set -e; \
|
|
for linux in /boot/*/*/linux; do \
|
|
[ -e "$linux" ] || continue; \
|
|
dir="$(dirname "$linux")"; \
|
|
kver="$(basename "$dir")"; \
|
|
initrd="${dir}/initrd"; \
|
|
[ -e "$initrd" ] || continue; \
|
|
ln -sf "${linux#/boot/}" "/boot/vmlinuz-${kver}"; \
|
|
ln -sf "${initrd#/boot/}" "/boot/initramfs-${kver}.img"; \
|
|
done
|
|
{{- else }}
|
|
RUN cd /boot && \
|
|
mv $(find / -name 'vmlinuz*') /boot/vmlinuz && \
|
|
mv $(find . -name 'initramfs-*.img' -o -name initrd) /boot/initrd.img
|
|
{{- end }}
|
|
|
|
RUN yum clean all && \
|
|
rm -rf /var/cache/yum
|
|
|
|
FROM scratch
|
|
|
|
COPY --from=rootfs / /
|