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