说明
- 服务器版本
CentOS Linux 7
- 常用的
Docker
镜像有两个garethflowers/svn-server
和elleflorio/svn-server
,本文使用的是elleflorio/svn-server
,因为集成了管理界面并且支持http协议
安装Docker
- 执行
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
安装docker
,其他安装方式参考 CentOS Docker 安装 - 执行
sudo systemctl start docker
启动docker
- 执行
sudo systemctl enable docker
添加docker
开机启动 - 执行
docker -v
查看是否安装成功[root@localhost ~]# docker -v Docker version 23.0.4, build f480fb1
- 执行
systemctl stop firewalld.service
关闭防火墙 - 执行
systemctl disable firewalld.service
关闭防火墙开机启动
安装svn
- 在宿主机中创建目录,用于存放
svn
的相关文件- 执行
mkdir -p /home/svndata/repository
创建目录,用来存放svn
的仓库 - 执行
mkdir -p /home/svndata/subversion
创建目录,用来存放subversion-access-control
与passwd
文件 - 执行
mkdir -p /home/svndata/svnadmin/data
创建目录,用来存放管理界面的配置文件 - 执行
mkdir -p /home/svndata/apache2
创建目录,用来存放/etc/apache2/httpd.conf
,解决svn
启动报错AH00558: httpd
- 执行
- 启动容器,先不要挂载目录
- 执行
docker run -d --name svn-server -p 8080:80 -p 3690:3690 elleflorio/svn-server:latest
启动容器 -
执行
docker logs --tail 500 svn-server
查看日志,启动成功日志如下,日志中的报错AH00558: httpd
后续再处理[root@localhost ~]# docker logs --tail 500 svn-server [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] 01-resolver-resolv: applying... [fix-attrs.d] 01-resolver-resolv: exited 0. [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] 30-resolver: executing... [cont-init.d] 30-resolver: exited 0. [cont-init.d] 40-resolver: executing... [cont-init.d] 40-resolver: exited 0. [cont-init.d] done. [services.d] starting services AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.6. Set the 'ServerName' directive globally to suppress this message [services.d] done.
- 执行
- 将相关文件拷贝到宿主机
- 执行
docker cp svn-server:/etc/subversion /home/svndata
- 执行
docker cp svn-server:/opt/svnadmin/data /home/svndata/svnadmin
- 执行
docker cp svn-server:/etc/apache2/httpd.conf /home/svndata/apache2/httpd.conf
- 执行
- 修改
httpd.conf
,解决启动时报错AH00558: httpd
-
找到
/home/svndata/apache2/httpd.conf
文件中的ServerName
,复制一行改为本机域名或ip+端口,如下# # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 # 改为自己的域名或ip+端口 ServerName 10.10.1.27:8080 # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. #
-
- 重新启动容器,并挂载目录
- 执行
chmod 777 -R /home/svndata/*
修改挂载的目录权限 - 执行
docker stop svn-server
停止旧容器 - 执行
docker rm svn-server
删除旧容器 -
执行如下命令,启动容器并挂载目录
docker run -d -v /home/svndata/repository:/home/svn -v /home/svndata/subversion:/etc/subversion -v /home/svndata/svnadmin/data:/opt/svnadmin/data -v /home/svndata/apache2/httpd.conf:/etc/apache2/httpd.conf --name svn-server -p 8080:80 -p 3690:3690 elleflorio/svn-server:latest
-
执行
docker logs --tail 500 svn-server
查看日志,启动成功日志如下[root@localhost ~]# docker logs --tail 500 svn-server [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] 01-resolver-resolv: applying... [fix-attrs.d] 01-resolver-resolv: exited 0. [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] 30-resolver: executing... [cont-init.d] 30-resolver: exited 0. [cont-init.d] 40-resolver: executing... [cont-init.d] 40-resolver: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done.
- 执行
-
浏览器访问管理界面
http://10.10.1.27:8080/svnadmin
,填写配置文件路径Subversion authorization file: /etc/subversion/subversion-access-control User authentication file (SVNUserFile):/etc/subversion/passwd Parent directory of the repositories (SVNParentPath):/home/svn Subversion client executable:/usr/bin/svn Subversion admin executable:/usr/bin/svnadmin
填写后点击Test
按钮,全部显示Test passed.
后,点击页面底部的Save configuration
保存配置
保存成功后,会自动创建管理员User: admin Password: admin
,点击login now
登录管理员帐号
- 管理端创建仓库后,需要给用户设置权限才能使用
- 我使用的是小乌龟
TortoiseSVN
,检出版本库URL为http://服务器ip:8080/svn/仓库名称
问题
无法提交大文件和提交超时
-
如果使用了
Nginx
,需要修改配置client_max_body_size 10240m # 设置文件上传大小限制 proxy_send_timeout 600s # 设置发送超时时间 proxy_read_timeout 600s # 设置读取超时时间
-
本项目使用的是阿里云
容器服务 Kubernetes 版
,需要添加Ingress
注解nginx.ingress.kubernetes.io/proxy-body-size:10240m nginx.ingress.kubernetes.io/proxy-connect-timeout:600 nginx.ingress.kubernetes.io/proxy-read-timeout:600 nginx.ingress.kubernetes.io/proxy-send-timeout:600