Gitblit 服务器搭建Gitblit 是一个用Java写的开源Git存储库软件,用于管理、查看和服务,它涉及之初是为了方便小型工作组设计的工具
Demo: http://git.wang-li.top:9010 用户名:project1密码:project1
快速使用
使用Docker快速试用
docker pull image
# docker pull docker.io/2859413527/gitblit
Run container
# docker run -d --restart=always --name gitblit-server -p 9010:9010 -p 29418:29418 -v /git:/git docker.io/2859413527/gitblit
Now, you can access it through the browser ip:9010, the default username and password are admin:admin
Other
If you need to map the git directory to -v when running the docker container, you need to consider the selinux factor, and shut down selinux during the test.
# setenforce 0
ps: 如果要在生产环境中使用gitblit,那么一定 要将磁盘挂载出来,即使用-v /git:/git,后期若因为docker出现问题,或者是gitblit需要初始化等,直接删除容器,再使用docker run启动一个便是,数据不会丢掉的。
Docker dockerfile文件
FROM centos
LABEL MAINTAINER 'liwang <2859413527@QQ.COM>'
# 设置gitblit版本的环境变量
ENV GITBLITVERSION 1.8.0
# 从官网将其gitblit下载至容器的/目录下
ADD http://dl.bintray.com/gitblit/releases/gitblit-${GITBLITVERSION}.tar.gz /gitblit-${GITBLITVERSION}.tar.gz
# 将工作目录设置 /
WORKDIR /
# 使用yum安装openjdk
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
# 对下载的gitblit进行解压
# 解压完毕后删除刚刚下载的压缩包
# 修改gitblit配置文件的httpPort和repositoriesFolder
RUN set -x \
&& tar xf gitblit-${GITBLITVERSION}.tar.gz \
&& rm -f gitblit-${GITBLITVERSION}.tar.gz \
&& cd gitblit-${GITBLITVERSION}/data \
&& mkdir /git \
&& sed -i 's/server.httpPort = 0/server.httpPort = 9010/g' defaults.properties \
&& sed -i 's#git.repositoriesFolder = ${baseFolder}/git#git.repositoriesFolder = /git#g' defaults.properties
# 将工作目录设置为刚刚解压的gitblit目录中
WORKDIR /gitblit-${GITBLITVERSION}
# 开放 9010 和 29418 端口
EXPOSE 9010
EXPOSE 29418
# 启动gitblit
CMD ["/usr/bin/java","-jar","gitblit.jar","--baseFolder","data"]
也可以手动复制该dockerfile文件,手动build成镜像
安装使用备注: Gitblit需要Java 7运行时环境(JRE)或Java 7开发套件(JDK)。
安装Java环境
# yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
下载gitblit包/解压
(这里最新版本是1.9.1,所以尝试1.9.1)
# cd /u
# wget https://github.com/gitblit/gitblit/releases/download/v1.9.1/gitblit-1.9.1.tar.gz
# tar xf gitblit-1.9.1.tar.gz
配置Gitblit
修改 data/defaults.properties 文件,第2069行 server.httpPort = 0 修改为 server.httpPort = 9010
# grep "server.httpPort" -C 10 data/defaults.properties -n
2059-# SINCE 0.7.0
2060-# RESTART REQUIRED
2061-server.contextPath = /
2062-
2063-# Standard http port to serve. <= 0 disables this connector.
2064-# On Unix/Linux systems, ports < 1024 require root permissions.
2065-# Recommended value: 80 or 8080
2066-#
2067-# SINCE 0.5.0
2068-# RESTART REQUIRED
2069:server.httpPort = 9010
2070-
2071-# Secure/SSL https port to serve. <= 0 disables this connector.
2072-# On Unix/Linux systems, ports < 1024 require root permissions.
2073-# Recommended value: 443 or 8443
2074-#
2075-# SINCE 0.5.0
2076-# RESTART REQUIRED
2077-server.httpsPort = 8443
2078-
2079-# Automatically redirect http requests to the secure https connector.
2080-#
2081:# This setting requires that you have configured server.httpPort and server.httpsPort.
2082-# Unless you are on a private LAN where you trust all client connections, it is
2083-# recommended to use https for all communications.
2084-#
2085-# SINCE 1.4.0
2086-# RESTART REQUIRED
2087-server.redirectToHttpsPort = false
2088-
2089-# Specify the interface for Jetty to bind the standard connector.
2090-# You may specify an ip or an empty value to bind to all interfaces.
2091-# Specifying localhost will result in Gitblit ONLY listening to requests to
#
启服
退回到gitblit 目录,执行gitblit.sh脚本即可
[root@localhost gitblit-1.9.1]# bash gitblit.sh
2020-08-12 18:14:19 [INFO ]
_____ _ _ _ _ _ _
| __ \(_)| | | | | |(_)| |
| | \/ _ | |_ | |__ | | _ | |_
| | __ | || __|| '_ \| || || __| http://gitblit.com
| |_\ \| || |_ | |_) || || || |_ @gitblit
\____/|_| \__||_.__/ |_||_| \__| 1.9.1
2020-08-12 18:14:19 [INFO ] Running on Linux (3.10.0-957.el7.x86_64)
2020-08-12 18:14:19 [INFO ] JVM version 1.8.0_262 (Oracle Corporation)
2020-08-12 18:14:19 [INFO ] Logging initialized @790ms
2020-08-12 18:14:20 [INFO ] Using JCE Unlimited Strength Jurisdiction Policy files
2020-08-12 18:14:20 [INFO ] Generating Gitblit Certificate Authority (/usr/local/gitblit-1.9.1/data/certs/caKeyStore.p12)
2020-08-12 18:14:21 [INFO ] Generating Gitblit Certificate Authority CRL (/usr/local/gitblit-1.9.1/data/certs/caRevocationList.crl)
2020-08-12 18:14:21 [INFO ] Generating SSL certificate for localhost signed by Gitblit Certificate Authority (/usr/local/gitblit-1.9.1/data/serverKeyStore.jks)
2020-08-12 18:14:22 [INFO ] Importing Gitblit Certificate Authority into trust store (/usr/local/gitblit-1.9.1/data/serverTrustStore.jks)
2020-08-12 18:14:22 [INFO ] Setting up HTTPS transport on port 8443
2020-08-12 18:14:22 [INFO ] certificate alias = localhost
2020-08-12 18:14:22 [INFO ] keyStorePath = /usr/local/gitblit-1.9.1/data/serverKeyStore.jks
2020-08-12 18:14:22 [INFO ] trustStorePath = /usr/local/gitblit-1.9.1/data/serverTrustStore.jks
2020-08-12 18:14:22 [INFO ] crlPath = /usr/local/gitblit-1.9.1/data/certs/caRevocationList.crl
2020-08-12 18:14:22 [INFO ] Setting up HTTP transport on port 9010
2020-08-12 18:14:22 [INFO ] Shutdown Monitor listening on port 8081
2020-08-12 18:14:22 [INFO ] jetty-9.2.13.v20150730
2020-08-12 18:14:22 [INFO ] NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-08-12 18:14:23 [INFO ]
2020-08-12 18:14:23 [INFO ] ----[com.gitblit.manager.IRuntimeManager]----
2020-08-12 18:14:23 [INFO ] Basefolder : /usr/local/gitblit-1.9.1/data
2020-08-12 18:14:23 [INFO ] Settings : /usr/local/gitblit-1.9.1/data/gitblit.properties
2020-08-12 18:14:23 [INFO ] JVM timezone: Asia/Shanghai (CST +0800)
2020-08-12 18:14:23 [INFO ] App timezone: Asia/Shanghai (CST +0800)
2020-08-12 18:14:23 [INFO ] JVM locale : en_US
2020-08-12 18:14:23 [INFO ] App locale :
...
2020-08-12 18:14:28 [INFO ] Started o.e.j.w.WebAppContext@5118388b{/,file:/usr/local/gitblit-1.9.1/data/temp/webapp/,AVAILABLE}{file:/usr/local/gitblit-1.9.1/gitblit.jar}
2020-08-12 18:14:28 [INFO ] Started ServerConnector@6e46d9f4{SSL-HTTP/1.1}{0.0.0.0:8443}
2020-08-12 18:14:28 [INFO ] Started ServerConnector@5cc69cfe{HTTP/1.1}{0.0.0.0:9010}
2020-08-12 18:14:28 [INFO ] Started @9143ms