[gitblit] Upgrade to latest version and add repo init feature

This commit is contained in:
Geoff Bourne
2016-06-11 18:18:17 -05:00
parent c806c425fd
commit 63035c347b
3 changed files with 124 additions and 24 deletions
+13 -17
View File
@@ -1,30 +1,26 @@
FROM itzg/ubuntu-openjdk-7 FROM java:8
MAINTAINER itzg MAINTAINER itzg
ENV APT_GET_UPDATE 2014-07-19 ENV GITBLIT_VERSION 1.7.1
RUN apt-get update RUN wget -qO /tmp/gitblit.tgz http://dl.bintray.com/gitblit/releases/gitblit-$GITBLIT_VERSION.tar.gz
RUN apt-get -y install wget tar
ENV GITBLIT_VERSION 1.6.0 RUN tar -C /opt -xvf /tmp/gitblit.tgz && \
rm /tmp/gitblit.tgz
RUN wget -O /tmp/gitblit.tgz http://dl.bintray.com/gitblit/releases/gitblit-$GITBLIT_VERSION.tar.gz
RUN mkdir /opt/gitblit
RUN tar -C /opt/gitblit -xvf /tmp/gitblit.tgz
RUN rm /tmp/gitblit.tgz
VOLUME ["/data"] VOLUME ["/data"]
ADD start.sh /start ADD start.sh /start
WORKDIR /opt/gitblit ENV GITBLIT_PATH=/opt/gitblit-${GITBLIT_VERSION} \
ENV GITBLIT_PATH /opt/gitblit GITBLIT_HTTPS_PORT=443 \
ENV GITBLIT_HTTPS_PORT 443 GITBLIT_HTTP_PORT=80 \
ENV GITBLIT_HTTP_PORT 80 GITBLIT_BASE_FOLDER=/data \
ENV GITBLIT_BASE_FOLDER /data GITBLIT_ADMIN_USER=admin \
GITBLIT_INITIAL_REPO=
WORKDIR $GITBLIT_PATH
EXPOSE 80 443 EXPOSE 80 443
CMD ["/start"] ENTRYPOINT ["/start"]
+36 -2
View File
@@ -1,5 +1,39 @@
Provides a ready-to-use instance of [GitBlit](http://gitblit.com/). In order to allow for Provides a ready-to-use instance of [GitBlit](http://gitblit.com/).
future upgrades run the container with a volume mount of `/data`, such as:
## Basic usage
Start the GitBlit container using
docker run -d -p 80:80 p 443:443 --name gitblit itzg/gitblit
Access its web interface at the mapped HTTP (80) or HTTPS (443) port of the
Docker host. Login with the default credentials __admin__ / __admin__ .
## Data volume
In order to allow for future upgrades, run the container with a volume mount of `/data`, such as:
docker run -d -p 80:80 p 443:443 -v /tmp/gitblit-data:/data --name gitblit itzg/gitblit docker run -d -p 80:80 p 443:443 -v /tmp/gitblit-data:/data --name gitblit itzg/gitblit
## Initial repository creation
As a convenience for cluster configuration management with git
(such as with [Spring Cloud Config](https://cloud.spring.io/spring-cloud-config/)),
you may specify the name of an initial repository to be owned by the 'admin' user.
This can be enabled by passing the name of that repository via the environment
variable `GITBLIT_INITIAL_REPO`, such as
-e GITBLIT_INITIAL_REPO=default
## Custom configuration
You can add or override any of the `*.properties` files for configuring GitBlit,
typically `gitblit.properties`, by placing those files in a volume attached at
`/config`, such as
-v $(pwd)/extra:/config
The property files in that configuration directory will be renamed with the
suffix `.applied` to avoid overwriting manually modified configuration on
the next container startup.
+75 -5
View File
@@ -1,10 +1,80 @@
#!/bin/sh #!/bin/bash
contents=`ls $GITBLIT_BASE_FOLDER|wc -l` apply_base_data() {
contents=`ls $GITBLIT_BASE_FOLDER|wc -l`
if [ $contents = "0" ]; then if [ $contents = "0" ]; then
cp -r $GITBLIT_PATH/data/* $GITBLIT_BASE_FOLDER cp -r $GITBLIT_PATH/data/* $GITBLIT_BASE_FOLDER
fi
}
apply_config() {
for p in /config/*.properties; do
echo "
APPLYING configuration file $p
"
cp $p $GITBLIT_BASE_FOLDER
mv $p ${p}.applied
done
}
create_initial_repo() {
if [ -d $GITBLIT_INITIAL_REPO ]; then
return
fi
echo "
CREATING initial repository '$GITBLIT_INITIAL_REPO' with:
* read/clone access for all
* push access for authenticated users
"
local repo_dir=$GITBLIT_BASE_FOLDER/git/${GITBLIT_INITIAL_REPO}.git
mkdir -p $repo_dir
cd $repo_dir
git init --bare
echo "
[gitblit]
description =
originRepository =
owner = $GITBLIT_ADMIN_USER
acceptNewPatchsets = true
acceptNewTickets = true
mergeTo = master
useIncrementalPushTags = false
allowForks = true
accessRestriction = PUSH
authorizationControl = AUTHENTICATED
verifyCommitter = false
showRemoteBranches = false
isFrozen = false
skipSizeCalculation = false
skipSummaryMetrics = false
federationStrategy = FEDERATE_THIS
isFederated = false
gcThreshold =
gcPeriod = 0
" >> config
git config --replace-all core.logallrefupdates false
cd $GITBLIT_PATH
}
shopt -s nullglob
apply_base_data
if [ -d /config ]; then
apply_config
fi fi
$JAVA_HOME/bin/java -jar $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT --baseFolder $GITBLIT_BASE_FOLDER if [[ -n $GITBLIT_INITIAL_REPO ]]; then
create_initial_repo
fi
$JAVA_HOME/bin/java -jar $GITBLIT_PATH/gitblit.jar \
--httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT \
--baseFolder $GITBLIT_BASE_FOLDER