|
1 | | -FROM alpine:3.4 |
| 1 | +FROM alpine:3.8 |
2 | 2 |
|
3 | | -MAINTAINER Carlos Bernárdez "carlos@z4studios.com" |
| 3 | +LABEL maintainer='Carlos Bernárdez <carlos@z4studios.com>' |
4 | 4 |
|
5 | | -# "--no-cache" is new in Alpine 3.3 and it avoid using |
6 | | -# "--update + rm -rf /var/cache/apk/*" (to remove cache) |
7 | | -RUN apk add --no-cache \ |
8 | | -# openssh=7.2_p2-r1 \ |
9 | | - openssh \ |
10 | | -# git=2.8.3-r0 |
11 | | - git |
12 | | - |
13 | | -# Key generation on the server |
14 | | -RUN ssh-keygen -A |
15 | | - |
16 | | -# SSH autorun |
17 | | -# RUN rc-update add sshd |
| 5 | +RUN apk add --no-cache openssh git |
18 | 6 |
|
19 | 7 | WORKDIR /git-server/ |
20 | 8 |
|
| 9 | +RUN mkdir -p keys-host/etc/ssh && \ |
| 10 | + ssh-keygen -A -f keys-host && \ |
| 11 | + mv keys-host/etc/ssh/* keys-host && \ |
| 12 | + rm -rf keys-host/etc |
| 13 | + |
21 | 14 | # -D flag avoids password generation |
22 | 15 | # -s flag changes user's shell |
23 | | -RUN mkdir /git-server/keys \ |
24 | | - && adduser -D -s /usr/bin/git-shell git \ |
25 | | - && echo git:12345 | chpasswd \ |
26 | | - && mkdir /home/git/.ssh |
| 16 | +RUN mkdir keys && \ |
| 17 | + adduser -D -s /usr/bin/git-shell git && \ |
| 18 | + echo git:12345 | chpasswd && \ |
| 19 | + mkdir /home/git/.ssh |
27 | 20 |
|
28 | 21 | # This is a login shell for SSH accounts to provide restricted Git access. |
29 | 22 | # It permits execution only of server-side Git commands implementing the |
30 | 23 | # pull/push functionality, plus custom commands present in a subdirectory |
31 | 24 | # named git-shell-commands in the user’s home directory. |
32 | 25 | # More info: https://git-scm.com/docs/git-shell |
33 | | -COPY git-shell-commands /home/git/git-shell-commands |
| 26 | +COPY git-shell-commands /home/git/git-shell-commands |
34 | 27 |
|
35 | 28 | # sshd_config file is edited for enable access key and disable access password |
36 | | -COPY sshd_config /etc/ssh/sshd_config |
37 | | -COPY start.sh start.sh |
| 29 | +COPY sshd_config /etc/ssh/sshd_config |
| 30 | + |
| 31 | +COPY start.sh start.sh |
| 32 | + |
| 33 | +EXPOSE 22 |
38 | 34 |
|
39 | | -EXPOSE 22 |
| 35 | +VOLUME ["/git/server/keys", "/git-server/keys-host", "/git-server/repos"] |
40 | 36 |
|
41 | | -CMD ["sh", "start.sh"] |
| 37 | +CMD ["sh", "start.sh"] |
0 commit comments