forked from jdeathe/centos-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
186 lines (175 loc) · 6.4 KB
/
Dockerfile
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# =============================================================================
# jdeathe/centos-ssh
#
# CentOS-7 7.3.1611 x86_64 - SCL/EPEL/IUS Repos. / Supervisor / OpenSSH.
#
# =============================================================================
FROM centos:7.3.1611
# -----------------------------------------------------------------------------
# Base Install + Import the RPM GPG keys for Repositories
# -----------------------------------------------------------------------------
RUN rpm --rebuilddb \
&& rpm --import \
http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 \
&& rpm --import \
https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 \
&& rpm --import \
https://dl.iuscommunity.org/pub/ius/IUS-COMMUNITY-GPG-KEY \
&& yum -y install \
--setopt=tsflags=nodocs \
--disableplugin=fastestmirror \
centos-release-scl \
centos-release-scl-rh \
epel-release \
https://centos7.iuscommunity.org/ius-release.rpm \
openssh-6.6.1p1-35.el7_3 \
openssh-server-6.6.1p1-35.el7_3 \
openssh-clients-6.6.1p1-35.el7_3 \
openssl-1.0.1e-60.el7 \
python-setuptools-0.9.8-4.el7 \
sudo-1.8.6p7-21.el7_3 \
vim-minimal-7.4.160-1.el7_3.1 \
yum-plugin-versionlock-1.1.31-40.el7 \
xz-5.2.2-1.el7 \
&& yum versionlock add \
openssh \
openssh-server \
openssh-clients \
python-setuptools \
sudo \
vim-minimal \
yum-plugin-versionlock \
xz \
&& yum clean all \
&& rm -rf /etc/ld.so.cache \
&& rm -rf /sbin/sln \
&& rm -rf /usr/{{lib,share}/locale,share/{man,doc,info,cracklib,i18n},{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive} \
&& rm -rf /{root,tmp,var/cache/{ldconfig,yum}}/* \
&& > /etc/sysconfig/i18n
# -----------------------------------------------------------------------------
# Install supervisord (required to run more than a single process in a container)
# Note: EPEL package lacks /usr/bin/pidproxy
# We require supervisor-stdout to allow output of services started by
# supervisord to be easily inspected with "docker logs".
# -----------------------------------------------------------------------------
RUN easy_install \
'supervisor == 3.3.1' \
'supervisor-stdout == 0.1.1' \
&& mkdir -p \
/var/log/supervisor/
# -----------------------------------------------------------------------------
# UTC Timezone & Networking
# -----------------------------------------------------------------------------
RUN ln -sf \
/usr/share/zoneinfo/UTC \
/etc/localtime \
&& echo "NETWORKING=yes" > /etc/sysconfig/network
# -----------------------------------------------------------------------------
# Configure SSH for non-root public key authentication
# -----------------------------------------------------------------------------
RUN sed -i \
-e 's~^PasswordAuthentication yes~PasswordAuthentication no~g' \
-e 's~^#PermitRootLogin yes~PermitRootLogin no~g' \
-e 's~^#UseDNS yes~UseDNS no~g' \
-e 's~^\(.*\)/usr/libexec/openssh/sftp-server$~\1internal-sftp~g' \
/etc/ssh/sshd_config
# -----------------------------------------------------------------------------
# Enable the wheel sudoers group
# -----------------------------------------------------------------------------
RUN sed -i \
-e 's~^# %wheel\tALL=(ALL)\tALL~%wheel\tALL=(ALL) ALL~g' \
-e 's~\(.*\) requiretty$~#\1requiretty~' \
/etc/sudoers
# -----------------------------------------------------------------------------
# Copy files into place
# -----------------------------------------------------------------------------
ADD src/usr/sbin \
/usr/sbin/
ADD src/opt/scmi \
/opt/scmi/
ADD src/etc/systemd/system \
/etc/systemd/system/
ADD src/etc/services-config/ssh/authorized_keys \
src/etc/services-config/ssh/sshd-bootstrap.conf \
src/etc/services-config/ssh/sshd-bootstrap.env \
/etc/services-config/ssh/
ADD src/etc/services-config/supervisor/supervisord.conf \
/etc/services-config/supervisor/
ADD src/etc/services-config/supervisor/supervisord.d \
/etc/services-config/supervisor/supervisord.d/
RUN mkdir -p \
/etc/supervisord.d/ \
&& cp -pf \
/etc/ssh/sshd_config \
/etc/services-config/ssh/ \
&& ln -sf \
/etc/services-config/ssh/sshd_config \
/etc/ssh/sshd_config \
&& ln -sf \
/etc/services-config/ssh/sshd-bootstrap.conf \
/etc/sshd-bootstrap.conf \
&& ln -sf \
/etc/services-config/ssh/sshd-bootstrap.env \
/etc/sshd-bootstrap.env \
&& ln -sf \
/etc/services-config/supervisor/supervisord.conf \
/etc/supervisord.conf \
&& ln -sf \
/etc/services-config/supervisor/supervisord.d/sshd-wrapper.conf \
/etc/supervisord.d/sshd-wrapper.conf \
&& ln -sf \
/etc/services-config/supervisor/supervisord.d/sshd-bootstrap.conf \
/etc/supervisord.d/sshd-bootstrap.conf \
&& chmod 700 \
/usr/sbin/{scmi,sshd-{bootstrap,wrapper}}
EXPOSE 22
# -----------------------------------------------------------------------------
# Set default environment variables
# -----------------------------------------------------------------------------
ENV SSH_AUTHORIZED_KEYS="" \
SSH_AUTOSTART_SSHD=true \
SSH_AUTOSTART_SSHD_BOOTSTRAP=true \
SSH_CHROOT_DIRECTORY="%h" \
SSH_INHERIT_ENVIRONMENT=false \
SSH_SUDO="ALL=(ALL) ALL" \
SSH_USER="app-admin" \
SSH_USER_FORCE_SFTP=false \
SSH_USER_HOME="/home/%u" \
SSH_USER_ID="500:500" \
SSH_USER_PASSWORD="" \
SSH_USER_PASSWORD_HASHED=false \
SSH_USER_SHELL="/bin/bash"
# -----------------------------------------------------------------------------
# Set image metadata
# -----------------------------------------------------------------------------
ARG RELEASE_VERSION="2.2.2"
LABEL \
maintainer="James Deathe <[email protected]>" \
install="docker run \
--rm \
--privileged \
--volume /:/media/root \
jdeathe/centos-ssh:${RELEASE_VERSION} \
/usr/sbin/scmi install \
--chroot=/media/root \
--name=\${NAME} \
--tag=${RELEASE_VERSION} \
--setopt='--volume {{NAME}}.config-ssh:/etc/ssh'" \
uninstall="docker run \
--rm \
--privileged \
--volume /:/media/root \
jdeathe/centos-ssh:${RELEASE_VERSION} \
/usr/sbin/scmi uninstall \
--chroot=/media/root \
--name=\${NAME} \
--tag=${RELEASE_VERSION} \
--setopt='--volume {{NAME}}.config-ssh:/etc/ssh'" \
org.deathe.name="centos-ssh" \
org.deathe.version="${RELEASE_VERSION}" \
org.deathe.release="jdeathe/centos-ssh:${RELEASE_VERSION}" \
org.deathe.license="MIT" \
org.deathe.vendor="jdeathe" \
org.deathe.url="https://github.com/jdeathe/centos-ssh" \
org.deathe.description="CentOS-7 7.3.1611 x86_64 - SCL, EPEL and IUS Repositories / Supervisor / OpenSSH."
CMD ["/usr/bin/supervisord", "--configuration=/etc/supervisord.conf"]