From d112d726c54cab76cfaa29d2cdc8ad2fd7658fb1 Mon Sep 17 00:00:00 2001 From: Ilolm Date: Wed, 20 Nov 2024 21:22:07 +0200 Subject: [PATCH] Optimized Dockerfiles 1.Reduced layers. 2.Reduced size by clearing the cache and combining RUN layers. --- ssh/baseline-configs/fedora+/Dockerfile | 18 ++++++++++++------ ssh/baseline-configs/fedora/Dockerfile | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ssh/baseline-configs/fedora+/Dockerfile b/ssh/baseline-configs/fedora+/Dockerfile index b7c0fbc..10e632e 100644 --- a/ssh/baseline-configs/fedora+/Dockerfile +++ b/ssh/baseline-configs/fedora+/Dockerfile @@ -1,13 +1,19 @@ FROM fedora:latest -RUN dnf install -y openssh-server wget +RUN dnf check-update || true && \ + dnf install -y openssh-server wget && \ + dnf clean all && \ -RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config -RUN sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config + # Configuring ssh config + sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ + sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \ -RUN ssh-keygen -A + # Generating ssh keys + ssh-keygen -A && \ -RUN echo "root:foobar" | chpasswd + # Changing root password + echo "root:foobar" | chpasswd EXPOSE 5670 -CMD ["/usr/sbin/sshd", "-D", "-p", "5670"] \ No newline at end of file + +CMD ["/usr/sbin/sshd", "-D", "-p", "5670"] diff --git a/ssh/baseline-configs/fedora/Dockerfile b/ssh/baseline-configs/fedora/Dockerfile index f8b725f..cd4d3f0 100644 --- a/ssh/baseline-configs/fedora/Dockerfile +++ b/ssh/baseline-configs/fedora/Dockerfile @@ -1,15 +1,21 @@ FROM fedora:latest -RUN dnf install -y openssh-server +RUN dnf check-update || true && \ + dnf install -y openssh-server && \ + dnf clean all && \ -RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config -RUN sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config + # Configuring ssh config + sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ + sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \ -RUN ssh-keygen -A + # Generating ssh keys + ssh-keygen -A && \ -RUN echo "root:foobar" | chpasswd + # Changing root password + echo "root:foobar" | chpasswd # TODO: expose only on an isolated docker network to avoid conflicts? # Think about how extension would communicate EXPOSE 5671 -CMD ["/usr/sbin/sshd", "-D", "-p", "5671"] \ No newline at end of file + +CMD ["/usr/sbin/sshd", "-D", "-p", "5671"]