forked from opsxcq/docker-test-git-ssh-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (27 loc) · 850 Bytes
/
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
FROM debian:9.2
LABEL maintainer "[email protected]"
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
git openssh-server sshpass \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN useradd --system --uid 666 -M --shell /usr/bin/git-shell git && \
echo git:secret | chpasswd && \
mkdir -p /home/git/.ssh && \
mkdir /run/sshd && \
chown -R git:git /home/git
COPY sshd.conf /etc/ssh/sshd_config
RUN mkdir /run/ssh
### Configure an empty git repository
WORKDIR /repo.git
RUN git init --bare && \
chown git -R /repo.git
EXPOSE 22
COPY main.sh /
ENTRYPOINT ["/main.sh"]
### Configure local key for healthcheck
WORKDIR /root/.ssh
RUN echo 'localhost '$(cat /etc/ssh/ssh_host_rsa_key.pub) >> known_hosts
COPY check.sh /
HEALTHCHECK --interval=10s --timeout=2s CMD /check.sh