-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
46 lines (37 loc) · 1.46 KB
/
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
39
40
41
42
43
44
45
46
# This file builds a docker image to run the git-lock server.
# The build will add the git-lock server binaries to the image
# from target/server.tar which will be generated by make.
# build image: $ docker build -t gitlock .
# run container: $ docker run -d -p 2222:22 --name gitlock gitlock
# add pubkek: $ docker exec -i -t gitlock /bin/bash
# $ echo "yourkey" >> /home/gitlock/.ssh/authorized_keys
FROM ubuntu:16.04
# add openssh
RUN apt-get update
RUN apt-get install -y vim openssh-server
RUN mkdir /var/run/sshd
RUN echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
# add gitlock binaries
ADD target/server.tar /gitlock-server
RUN chown -R root:root /gitlock-server
RUN chmod +x /gitlock-server/bin
RUN rm -rf /gitlock-server/lock-working-dir
# setup the gitlock user
RUN addgroup gitlock
RUN useradd -g gitlock -m gitlock
# setup .ssh/authorized_keys file for gitlock
RUN cd /home/gitlock && \
mkdir .ssh && \
chmod 700 .ssh && \
echo "# add team member public keys here" > .ssh/authorized_keys && \
chmod 600 .ssh/authorized_keys && \
chown -R gitlock:gitlock .ssh
# create a /data volume where we store the git-lock working data
RUN mkdir /data
RUN chown gitlock:gitlock /data
VOLUME /data
# setup the gitlock environment variables when user ssh into the host
RUN echo "LOCK_SERVER_BIN_DIR=/gitlock-server/bin" > /home/gitlock/.ssh/environment
RUN echo "LOCK_SERVER_DIR=/data" >> /home/gitlock/.ssh/environment
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]