Dockerfile (1153B)
1 FROM alpine:3.17 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 stagit 11 12 # Key generation on the server 13 RUN ssh-keygen -A 14 15 WORKDIR /git-server/ 16 17 # -D flag avoids password generation 18 # -s flag changes user's shell 19 RUN mkdir /git-server/keys \ 20 && adduser -D -s /usr/bin/git-shell git \ 21 && echo git:12345 | chpasswd \ 22 && mkdir /home/git/.ssh 23 RUN mkdir /git-server/repos 24 RUN mkdir /git-server/public-html 25 26 # sshd_config file is edited for enable access key and disable access password 27 COPY sshd_config /etc/ssh/sshd_config 28 29 COPY resources /git-server/resources 30 COPY start.sh start.sh 31 32 # This is a login shell for SSH accounts to provide restricted Git access. 33 # It permits execution only of server-side Git commands implementing the 34 # pull/push functionality, plus custom commands present in a subdirectory 35 # named git-shell-commands in the user’s home directory. 36 # More info: https://git-scm.com/docs/git-shell 37 COPY git-shell-commands /home/git/git-shell-commands 38 39 EXPOSE 22 40 41 CMD ["sh", "start.sh"]