-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile--alpine.tmpl
More file actions
94 lines (79 loc) · 2.84 KB
/
Copy pathDockerfile--alpine.tmpl
File metadata and controls
94 lines (79 loc) · 2.84 KB
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
ARG PYTHON_VERSION=3.12
# --------------------------------------------- base1
FROM python:${PYTHON_VERSION}-alpine AS base1
RUN apk add --no-cache \
coreutils \
bash \
mc \
procps \
openssh \
sshpass \
sudo \
git
RUN sed -i 's/#MaxStartups 10:30:100/MaxStartups 2000:30:2000/' /etc/ssh/sshd_config && \
sed -i 's/#MaxSessions 10/MaxSessions 500/' /etc/ssh/sshd_config && \
sed -i 's/#MaxAuthTries 6/MaxAuthTries 20/' /etc/ssh/sshd_config
ENV PYTHON_BINARY=python3
# --------------------------------------------- base2
FROM base1 AS base2
RUN apk add --no-cache \
python3-dev \
build-base\
musl-dev \
linux-headers
# --------------------------------------------- final
FROM base2 AS final
RUN adduser -D test && addgroup -S sudo && adduser test sudo
EXPOSE 22
RUN ssh-keygen -A
COPY --chown=test:test . /home/test/testgres
WORKDIR /home/test/testgres
# It allows to use sudo without password
RUN echo "test ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
# THIS CMD IS NEEDED TO CONNECT THROUGH SSH WITHOUT PASSWORD
RUN echo "test:*" | chpasswd -e
RUN chmod 700 /home/test/ && \
mkdir -p /home/test/.ssh && \
echo 'Host *' > /home/test/.ssh/config && \
echo ' ControlMaster auto' >> /home/test/.ssh/config && \
echo ' ControlPath /home/test/.ssh/master-%r@%h:%p' >> /home/test/.ssh/config && \
echo ' ControlPersist 30m' >> /home/test/.ssh/config && \
echo ' StrictHostKeyChecking no' >> /home/test/.ssh/config && \
echo ' UserKnownHostsFile /dev/null' >> /home/test/.ssh/config && \
# echo ' GSSAPIAuthentication no' >> /home/test/.ssh/config && \
chown -R test:test /home/test/.ssh && \
chmod 700 /home/test/.ssh && \
chmod 600 /home/test/.ssh/config
#
# \"$@\"
# - quote is important!
# - "DUMMY-DUMMY-DUMMY" will be ignored. Do not ask me "why?". AXEZ.
#
ENTRYPOINT ["sh", "-c", " \
set -eux; \
echo 'SYSTEM START: PREPARING SSH'; \
/usr/sbin/sshd; \
ls -la /home/test/.ssh/; \
\"$@\" \
", "DUMMY-DUMMY-DUMMY"]
# Run tests by default (master machine role)
CMD ["bash", "-c", " \
set -eux; \
echo \"HOME DIR IS [`realpath ~/`]\"; \
echo \"WORK DIR IS [$(pwd)]\"; \
if [ ! -f /home/test/.ssh/id_rsa ]; then \
su test -c \"ssh-keygen -t rsa -f /home/test/.ssh/id_rsa -q -N ''\"; \
su test -c \"cat /home/test/.ssh/id_rsa.pub >> /home/test/.ssh/authorized_keys\"; \
chmod 600 /home/test/.ssh/authorized_keys; \
fi; \
ls -la /home/test/.ssh/; \
if [ -n \"${TEST_CFG__REMOTE_SSH_KEY:-}\" ]; then \
cp \"${TEST_CFG__REMOTE_SSH_KEY}\" \"${TEST_CFG__REMOTE_SSH_KEY}_ci\"; \
export TEST_CFG__REMOTE_SSH_KEY=\"${TEST_CFG__REMOTE_SSH_KEY}_ci\"; \
chown test:test \"${TEST_CFG__REMOTE_SSH_KEY}\"; \
chmod 600 \"${TEST_CFG__REMOTE_SSH_KEY}\"; \
ls -la /home/test/.ssh/; \
fi; \
ls -la ./; \
su test -c \"bash ./run_tests3.sh\"; \
"]