Skip to content

Commit d112d72

Browse files
committed
Optimized Dockerfiles
1.Reduced layers. 2.Reduced size by clearing the cache and combining RUN layers.
1 parent da79791 commit d112d72

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
FROM fedora:latest
22

3-
RUN dnf install -y openssh-server wget
3+
RUN dnf check-update || true && \
4+
dnf install -y openssh-server wget && \
5+
dnf clean all && \
46

5-
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
6-
RUN sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config
7+
# Configuring ssh config
8+
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
9+
sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \
710

8-
RUN ssh-keygen -A
11+
# Generating ssh keys
12+
ssh-keygen -A && \
913

10-
RUN echo "root:foobar" | chpasswd
14+
# Changing root password
15+
echo "root:foobar" | chpasswd
1116

1217
EXPOSE 5670
13-
CMD ["/usr/sbin/sshd", "-D", "-p", "5670"]
18+
19+
CMD ["/usr/sbin/sshd", "-D", "-p", "5670"]
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
FROM fedora:latest
22

3-
RUN dnf install -y openssh-server
3+
RUN dnf check-update || true && \
4+
dnf install -y openssh-server && \
5+
dnf clean all && \
46

5-
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
6-
RUN sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config
7+
# Configuring ssh config
8+
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
9+
sed -i 's/#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \
710

8-
RUN ssh-keygen -A
11+
# Generating ssh keys
12+
ssh-keygen -A && \
913

10-
RUN echo "root:foobar" | chpasswd
14+
# Changing root password
15+
echo "root:foobar" | chpasswd
1116

1217
# TODO: expose only on an isolated docker network to avoid conflicts?
1318
# Think about how extension would communicate
1419
EXPOSE 5671
15-
CMD ["/usr/sbin/sshd", "-D", "-p", "5671"]
20+
21+
CMD ["/usr/sbin/sshd", "-D", "-p", "5671"]

0 commit comments

Comments
 (0)