forked from jdeathe/centos-ssh
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
174 lines (163 loc) · 5.43 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
FROM centos:7.6.1810
ARG RELEASE_VERSION="2.6.1"
# ------------------------------------------------------------------------------
# - Import the RPM GPG keys for repositories
# - Base install of required packages
# - Install supervisord (used to run more than a single process)
# - Install supervisor-stdout to allow output of services started by
# supervisord to be easily inspected with "docker logs".
# ------------------------------------------------------------------------------
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 \
&& yum -y install \
--setopt=tsflags=nodocs \
--disableplugin=fastestmirror \
inotify-tools-3.14-8.el7 \
openssh-clients-7.4p1-21.el7 \
openssh-server-7.4p1-21.el7 \
openssl-1.0.2k-19.el7 \
python-setuptools-0.9.8-7.el7 \
sudo-1.8.23-3.el7 \
glibc-common \
vim \
tree \
libaio \
numactl \
man \
iproute \
net-tools \
wget \
yum-plugin-versionlock-1.1.31-50.el7 \
sudo-1.8.23-4.el7 \
yum-plugin-versionlock-1.1.31-52.el7 \
&& yum versionlock add \
inotify-tools \
openssh \
openssh-server \
openssh-clients \
python-setuptools \
sudo \
yum-plugin-versionlock \
&& yum clean all \
&& easy_install \
'supervisor == 4.0.4' \
'supervisor-stdout == 0.1.1' \
&& mkdir -p \
/var/log/supervisor/ \
&& 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
# ------------------------------------------------------------------------------
# Copy files into place
# ------------------------------------------------------------------------------
ADD src /
# ------------------------------------------------------------------------------
# Provisioning
# - UTC Timezone
# - Networking
# - Configure SSH defaults for non-root public key authentication
# - Enable the wheel sudoers group
# - Replace placeholders with values in systemd service unit template
# - Set permissions
# ------------------------------------------------------------------------------
RUN ln -sf \
/usr/share/zoneinfo/Asia/Shanghai \
/etc/localtime \
&& echo "NETWORKING=yes" \
> /etc/sysconfig/network \
&& sed -i \
-e 's~^#UseDNS yes~UseDNS no~g' \
-e 's~^\(.*\)/usr/libexec/openssh/sftp-server$~\1internal-sftp~g' \
/etc/ssh/sshd_config \
&& sed -i \
-e 's~^# %wheel\tALL=(ALL)\tALL~%wheel\tALL=(ALL) ALL~g' \
-e 's~\(.*\) requiretty$~#\1requiretty~' \
/etc/sudoers \
&& sed -i \
-e "s~{{RELEASE_VERSION}}~${RELEASE_VERSION}~g" \
/etc/systemd/system/[email protected] \
&& chmod 644 \
/etc/{supervisord.conf,supervisord.d/{20-sshd-bootstrap,50-sshd-wrapper}.conf} \
&& chmod 700 \
/usr/{bin/healthcheck,sbin/{scmi,sshd-{bootstrap,wrapper}}} \
&& echo "root:zstzst"|chpasswd \
&& chown -R root:root /root/.ssh \
&& chmod 700 /root/.ssh \
&& chmod 600 /root/.ssh/* \
&& chmod 700 /usr/{bin/healthcheck,sbin/{scmi,sshd-{bootstrap,wrapper},system-{timezone,timezone-wrapper}}}
EXPOSE 22
# ------------------------------------------------------------------------------
# Set default environment variables
# ------------------------------------------------------------------------------
ENV \
ENABLE_SSHD_BOOTSTRAP="true" \
ENABLE_SSHD_WRAPPER="true" \
ENABLE_SUPERVISOR_STDOUT="false" \
SSH_AUTHORIZED_KEYS="" \
SSH_CHROOT_DIRECTORY="%h" \
SSH_INHERIT_ENVIRONMENT="false" \
SSH_PASSWORD_AUTHENTICATION="false" \
SSH_SUDO="ALL=(ALL) ALL" \
SSH_TIMEZONE="Asia/Shanghai" \
SSH_USER="wubx" \
SSH_USER="app-admin" \
SSH_USER_FORCE_SFTP="false" \
SSH_USER_HOME="/home/%u" \
SSH_USER_ID="500:500" \
SSH_USER_PASSWORD="zstzst" \
SSH_USER_PASSWORD_HASHED="false" \
SSH_USER_PRIVATE_KEY="" \
SSH_USER_SHELL="/bin/bash" \
SYSTEM_TIMEZONE="UTC"
# ------------------------------------------------------------------------------
# Set image metadata
# ------------------------------------------------------------------------------
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="OpenSSH 7.4 / Supervisor 4.0 / EPEL/IUS/SCL Repositories - CentOS-7 7.6.1810 x86_64."
HEALTHCHECK \
--interval=1s \
--timeout=1s \
--retries=5 \
CMD ["/usr/bin/healthcheck"]
CMD ["/usr/bin/supervisord", "--configuration=/etc/supervisord.conf"]