aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar Grégory Joubès <gregoryjoubesnetcourriercom>2020-11-04 12:59:58 +0100
committerLibravatarLarge Libravatar Grégory Joubès <gregoryjoubesnetcourriercom>2020-11-04 12:59:58 +0100
commita912704a1fdc06622466c9887051e1e0b2f5d42f (patch)
treea978007e14ff94454ac75356976a5863b6c79588
parent860fb6c4c8b1111a411e2587f394f2a9e8128716 (diff)
downloadcgit-oci-a912704a1fdc06622466c9887051e1e0b2f5d42f.tar.gz
cgit-oci-a912704a1fdc06622466c9887051e1e0b2f5d42f.tar.bz2
cgit-oci-a912704a1fdc06622466c9887051e1e0b2f5d42f.tar.lz
cgit-oci-a912704a1fdc06622466c9887051e1e0b2f5d42f.zip

Add a volume to manage SSH server keys. Add some clean up to reduce image size.

-rw-r--r--Dockerfile52
-rw-r--r--README.md22
-rwxr-xr-xprepare-container.sh2
3 files changed, 41 insertions, 35 deletions
diff --git a/Dockerfile b/Dockerfile
index 22a3210..f49018e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,33 +6,34 @@ WORKDIR /root
ARG HTTP_PROXY
-# Packages
-RUN apk update && apk add git openssh
-RUN apk add gcc make libressl-dev
-RUN apk add python3 py3-pygments
-RUN apk add py3-markdown
-RUN apk add linux-headers
-RUN ln -sf /usr/include/linux/unistd.h /usr/include/
-RUN apk add musl-dev
-RUN apk add libintl musl-libintl
-RUN apk add zlib zlib-dev
-# to support untar tar.xz
-RUN apk add tar
-# Vim is cool
-RUN apk add vim
+WORKDIR /root
-# Clean up
-RUN rm -rf /tmp/* /var/cache/apk/*
+# Packages we'll keep
+RUN apk update && apk add git openssh && \
+ apk add python3 py3-pygments && \
+ apk add py3-markdown && \
+ apk add libintl musl-libintl && \
+ apk add zlib
# cgit install
-WORKDIR /root
RUN git clone git://git.zx2c4.com/cgit
WORKDIR cgit
-RUN git submodule init
-RUN git submodule update
-RUN make install NO_LUA=1 NO_REGEX=NeedsStartEnd
-WORKDIR ../
-RUN rm -Rf cgit
+# Packages needed for build
+RUN apk update && apk add gcc make libressl-dev && \
+ apk add linux-headers && \
+ ln -sf /usr/include/linux/unistd.h /usr/include/ && \
+ apk add musl-dev zlib-dev && \
+# Build
+ git submodule init && \
+ git submodule update && \
+ make install NO_LUA=1 NO_REGEX=NeedsStartEnd && \
+# Clean up
+ cd ../ && \
+ rm -Rf cgit && \
+ apk del gcc make libressl-dev && \
+ apk del linux-headers musl-dev zlib-dev && \
+ rm -rf /tmp/* /var/cache/apk/*
+WORKDIR /root
# cgit config
ENV HTTP_AUTH_USER="", HTTP_AUTH_PASSWORD=""
@@ -44,8 +45,8 @@ RUN ln -s /home/git/cgitrc /etc/cgitrc
# Gitolite install
# Clone
-RUN git clone https://github.com/sitaramc/gitolite
-RUN gitolite/install -to /usr/local/bin/
+RUN git clone https://github.com/sitaramc/gitolite && \
+ gitolite/install -to /usr/local/bin/
# Default work dir for base image httpd
WORKDIR /usr/local/apache2
@@ -65,6 +66,9 @@ RUN adduser -D -g "" -s "/bin/ash" git
# We need a password set, otherwise pubkey auth doesn't work... why ?? /sbin/nologin doesn't work either
RUN echo "git:fhzefGG65gdoejdK$!dhd753" | chpasswd
+# Volume for server key
+VOLUME ["/etc/ssh"]
+
# Volume for /home/git
VOLUME ["/home/git"]
diff --git a/README.md b/README.md
index 70c1b60..acee003 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@ Image docker Gitolite/cgit
=========================
This [Docker][docker] image offers a very quick way of deploying a Gitolite / Cgit server. Gitolite is a lightweight yet powerful git manager. Cgit is web-based frontend to Git repositories.
+
+Based on Alpine Linux.
@@ -14,13 +16,13 @@ For more details about Gitolite setup, please read the [official documentation][
The container will stop by itself once the initial configuration is done. The `--rm` will make Docker remove it automatically. Only data will remain on the volume/bindmount.
- $ docker run --rm -dit -v git-data:/home/git -e SSH_KEY="$(cat /home/<user>/.ssh/id_rsa.pub)" gjbs84/gitolite-cgit:latest
+ $ docker run --rm -dit -v git-data:/home/git -v git-ssh:/etc/ssh -e SSH_KEY="$(cat /home/<user>/.ssh/id_rsa.pub)" gjbs84/gitolite-cgit:latest
-Default behavion is to save data into an internal named volume, `git-data` in this exemple. Of course you can change it if you wish.
+Default behavion is to save data into an internal named volume, `git-data` and `git-ssh` in this exemple. Of course you can change it if you wish.
-If it's suits you better you can use a bindmount. Here an exemple with `/srv/git-data`. No existing `repositories` directory must be there !
+If it's suits you better you can use a bindmount. Here an exemple with `/srv/git-data` and `/srv/git-ssh`. No existing `repositories` directory must be there !
- $ docker run --rm -dit -v /srv/git-data:/home/git -e SSH_KEY="$(cat /home/<user>/.ssh/id_rsa.pub)" gjbs84/gitolite-cgit:latest
+ $ docker run --rm -dit -v /srv/git-data:/home/git -v /srv/git-ssh:/etc/ssh -e SSH_KEY="$(cat /home/<user>/.ssh/id_rsa.pub)" gjbs84/gitolite-cgit:latest
### Troubleshooting
@@ -80,13 +82,13 @@ A good first startup looks like this :
## Final launch
-You can now run the final container. It will use the previoulsy created volume `git-data`. Now we can give a name to this container and we have to NAT ports 22 et 80 to the host. Of course you may have to adapt the command line to your network.
+You can now run the final container. It will use the previoulsy created volumes `git-data` and `git-ssh`. Now we can give a name to this container and we have to NAT ports 22 et 80 to the host. Of course you may have to adapt the command line to your network.
- $ docker run --name gitolite-cgit-srv -dit -v git-data:/home/git -p 20080:80 -p 20022:22 gjbs84/gitolite-cgit:lastest
+ $ docker run --name gitolite-cgit-srv -dit -v git-data:/home/git -v git-ssh:/etc/ssh -p 20080:80 -p 20022:22 gjbs84/gitolite-cgit:lastest
-If you have chosen the bindmount way (here `/srv/git-data`) :
+If you have chosen the bindmount way :
- $ docker run --name gitolite-cgit-srv -dit -v /srv/git-data:/home/git -p 20080:80 -p 20022:22 gjbs84/gitolite-cgit:lastest
+ $ docker run --name gitolite-cgit-srv -dit -v /srv/git-data:/home/git -v /srv/git-ssh:/etc/ssh -p 20080:80 -p 20022:22 gjbs84/gitolite-cgit:lastest
It's now time to check if everythings is right ! Let's clone the `testing` repository.
@@ -111,7 +113,7 @@ Git tells us this an empty repository, it's true so everything is fine so far.
## Updating / recreating container
-If you have deleted the exiting container or wish to update it with a newer version, just run the "Final launch" step again. The server RSA key will change but all your data are kept in Docker volume (or bindmount) .
+If you have deleted the exiting container or wish to update it with a newer version, just run the "Final launch" step again. All your data are kept in Docker volume (or bindmount) .
### .htaccess authentication
@@ -119,7 +121,7 @@ You may wish to protect access to the git fronted Cgit.
Just give fill up environnement variables `HTTP_AUTH_USER` and `HTTP_AUTH_PASSWORD` during the final launch step :
- $ docker run --name gitolite-cgit-srv -dit -v git-data:/home/git -p 20080:80 -p 20022:22 -e HTTP_AUTH_USER="my_user" -e HTTP_AUTH_PASSWORD="my_password" gjbs84/gitolite-cgit:latest
+ $ docker run --name gitolite-cgit-srv -dit -v git-data:/home/git -v git-ssh:/etc/ssh -p 20080:80 -p 20022:22 -e HTTP_AUTH_USER="my_user" -e HTTP_AUTH_PASSWORD="my_password" gjbs84/gitolite-cgit:latest
### Troubleshooting
diff --git a/prepare-container.sh b/prepare-container.sh
index 784b9eb..da8544d 100755
--- a/prepare-container.sh
+++ b/prepare-container.sh
@@ -33,7 +33,7 @@ if [ ! -f "/home/git/.ssh/authorized_keys" ]; then
rm "/tmp/admin.pub"
else
echo "You need to specify SSH_KEY on first run to setup gitolite"
- echo 'Example: docker run --rm --name git-test -e SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" -v git-data:/home/git -dit gitolite-cgit-cds:v10'
+ echo 'Example: docker run --rm -dit -v git-data:/home/git -v git-ssh:/etc/ssh -e SSH_KEY="$(cat /home/<user>/.ssh/id_rsa.pub)" gjbs84/gitolite-cgit:latest'
exit 1
fi
echo "First launch : container is now shut down"