Skip to content

Commit 61e3513

Browse files
Mas uma mudança no containerfile para melhorar as camadas
1 parent cd1cec0 commit 61e3513

1 file changed

Lines changed: 31 additions & 43 deletions

File tree

Containerfile

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,49 @@ RUN KERNEL_VERSION="$(rpm -q kernel-core --queryformat '%{VERSION}-%{RELEASE}.%{
88

99
# Segundo estágio: Configuração do sistema e imagem final
1010
FROM quay.io/fedora/fedora-bootc:44 AS final
11-
# 1. Instalação do kernel e módulos extras e crioação de diretórios de trabalho
11+
12+
# 1. Estrutura de diretórios e Kernel Extra
1213
RUN mkdir -vp /var/roothome /data /var/home && \
1314
kver="$(rpm -q kernel-core --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" && \
1415
dnf5 -y install "kernel-modules-extra-${kver}" && \
15-
dnf5 clean all && \
16-
rm -rfv /var/cache/* /var/lib/dnf/* /var/log/* /tmp/* /var/tmp/*
16+
dnf5 clean all
1717

18-
# 2. Instalação dos módulos e drivers NVIDIA compilados
18+
# 2. Instalação dos módulos NVIDIA compilados
1919
COPY --from=builder /etc/yum.repos.d/fedora-nvidia-580.repo /etc/yum.repos.d/
20-
COPY --from=builder /var/cache/akmods/nvidia/kmod-nvidia*.rpm ./
21-
RUN dnf5 download nvidia-kmod-common nvidia-driver-cuda && \
22-
rpm -vi --nodeps nvidia-kmod-common*.rpm && \
23-
rpm -vi --nodeps nvidia-driver-cuda*.rpm && \
24-
dnf5 -y install ./kmod-nvidia-*.rpm && \
25-
rm -rvf kmod-nvidia-*.rpm nvidia-kmod-common*.rpm nvidia-driver-cuda*.rpm && \
26-
dnf5 clean all && \
27-
rm -rfv /var/cache/* /var/lib/dnf/* /var/log/* /tmp/* /var/tmp/*
28-
29-
# 3. Pacotes base do ambiente gráfico GNOME Minimalista
30-
RUN dnf5 install gnome-shell --setopt=install_weak_deps=False -y && \
31-
dnf5 clean all && \
32-
rm -rfv /var/cache/* /var/lib/dnf/* /var/log/* /tmp/* /var/tmp/*
20+
COPY --from=builder /var/cache/akmods/nvidia/kmod-nvidia*.rpm /tmp/kmod/
21+
RUN dnf5 install -y nvidia-kmod-common nvidia-driver-cuda /tmp/kmod/*.rpm && \
22+
rm -rf /tmp/kmod && \
23+
dnf5 clean all
3324

34-
# 4. Listas de pacotes personalizadas
35-
# Copiadas separadamente para evitar a invalidação do cache do GNOME e NVIDIA
25+
# 3. Instalação do GNOME e Listas de Pacotes Personalizadas
3626
COPY pacotes_necessarios pacotes_desktop /tmp/
37-
RUN grep -v '^#' /tmp/pacotes_necessarios | tr '\n' ' ' | xargs dnf5 install -y && \
38-
grep -v '^#' /tmp/pacotes_desktop | tr '\n' ' ' | xargs dnf5 install -y && \
39-
dnf5 clean all && \
40-
rm -rfv /var/cache/* /var/lib/dnf/* /var/log/* /tmp/* /var/tmp/*
27+
RUN PKGS_BASE=$(grep -v '^#' /tmp/pacotes_necessarios | tr '\n' ' ') && \
28+
PKGS_DESK=$(grep -v '^#' /tmp/pacotes_desktop | tr '\n' ' ') && \
29+
dnf5 install -y --setopt=install_weak_deps=False gnome-shell $PKGS_BASE $PKGS_DESK && \
30+
rm -f /tmp/pacotes_necessarios /tmp/pacotes_desktop && \
31+
dnf5 clean all
32+
33+
# 4. Ajustes do Sistema e Links Simbólicos (Compatibilidade bootc)
34+
RUN rm -rf /opt && mkdir -vp /var/opt && ln -vs /var/opt /opt && \
35+
mkdir -vp /var/usrlocal && mv -v /usr/local/* /var/usrlocal/ 2>/dev/null || true && \
36+
rm -rf /usr/local && ln -vs /var/usrlocal /usr/local
37+
38+
# 5. Cópia Direta de Arquivos de Configuração e Scripts (Modificações Frequentes)
39+
COPY zram-generator.conf /etc/systemd/zram-generator.conf
40+
COPY vconsole.conf /etc/vconsole.conf
41+
COPY locale.conf /etc/locale.conf
42+
COPY 10-nvidia-args.toml /usr/lib/bootc/kargs.d/10-nvidia-args.toml
43+
COPY post-install.sh /usr/bin/post-install.sh
44+
COPY post-install.service /usr/lib/systemd/system/post-install.service
4145

42-
# 5. Configurações do sistema, scripts e links simbólicos (Arquivos com modificações frequentes)
43-
# Mantidos por último para que edições nesses arquivos executem em instantes
44-
COPY 10-nvidia-args.toml locale.conf post-install.sh post-install.service vconsole.conf zram-generator.conf ./
45-
RUN rm -rvf /opt && mkdir -vp /var/opt && ln -vs /var/opt /opt && \
46-
mkdir -vp /var/usrlocal && mv -v /usr/local/* /var/usrlocal/ && \
47-
rm -rvf /usr/local && ln -vs /var/usrlocal /usr/local && \
48-
mv -v zram-generator.conf /etc/systemd/ && \
49-
mv -v vconsole.conf /etc/vconsole.conf && \
50-
mv -v locale.conf /etc/locale.conf && \
51-
mv -v 10-nvidia-args.toml /usr/lib/bootc/kargs.d/10-nvidia-args.toml && \
52-
mv -v post-install.sh /usr/bin/post-install.sh && \
53-
mv -v post-install.service /usr/lib/systemd/system/post-install.service && \
54-
chmod +x /usr/bin/post-install.sh && \
46+
# 6. Ativação de Serviços e Limpeza Final
47+
RUN chmod +x /usr/bin/post-install.sh && \
5548
systemctl enable post-install.service && \
5649
systemctl mask systemd-remount-fs.service && \
5750
systemctl mask akmods-keygen@akmods-keygen.service && \
5851
systemctl enable libvirtd.service && \
5952
systemctl enable spice-vdagentd.service && \
60-
rm -rfv /var/cache/* \
61-
/var/lib/* \
62-
/var/log/* \
63-
/var/tmp/* \
64-
/var/usrlocal/share/applications/mimeinfo.cache \
65-
/var/roothome/.*
53+
rm -rf /var/cache/* /var/lib/dnf/* /var/log/* /tmp/* /var/tmp/* /var/roothome/.*
6654

67-
# 6. Validação do bootc
55+
# 7. Validação do bootc
6856
RUN bootc container lint

0 commit comments

Comments
 (0)