安装前的准备准备
如果本机是首次使用docker-compose环境部署,需要在在/deploy/sorts创建以下脚本并执行 vi pre_install.sh
vi pre_install.sh
#!/bin/bash
###关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
###配置拉取国内镜像仓库
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://5sr5uink.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"insecure-registries": ["harbor.xxx.com"]
}
EOF
###启动docker
systemctl start docker
systemctl enable docker
### 下载docker-compose
curl -L "https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
docker-compose -version
sh pre_install.sh
创建svn目录和子目录
mkdir -p /deploy/sorts/svn/data/svn
编辑docker-compose.yml文件
cd /deploy/sorts/svn vi docker-compose.yml
svn:
image: harbor.xxx.com/xxx/svn-server
container_name: svn-server
ports:
- "80:80"
- "3690:3690"
volumes:
- /usr/share/zoneinfo/Asia/Shanghai:/usr/share/zoneinfo/Asia/Shanghai
- "./data/svn:/home/svn"
restart: always
environment:
- TZ=Asia/Shanghai
编辑启动和停止脚本
vi up.sh
#!/bin/bash
set -e
tm=`date +%Y%m%d-%H%M%S`
echo "====================================================="
echo "Starting svn."
echo "Starting <${tm}>."
echo "====================================================="
echo "Please ensure the config files right."
echo "====================================================="
docker-compose -p svn up -d
vi down.sh
#!/bin/bash
set -e
tm=`date +%Y%m%d-%H%M%S`
echo "====================================================="
echo "Stopping svn."
echo "Stopping <${tm}>."
echo "====================================================="
echo "Please ensure the config files right."
echo "====================================================="
docker-compose -p svn down
启动svn和查看状态
sh up.sh
[root@localhost-203-root-all svn]# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------------------------------
svn-server /init Up 0.0.0.0:3690->3690/tcp,:::3690->3690/tcp, 443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp
State字段为Up说明启动成功
查看日志
[root@localhost-203-root-all svn]# docker-compose logs svn
Attaching to svn-server
svn-server | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
svn-server | [s6-init] ensuring user provided files have correct perms...exited 0.
svn-server | [fix-attrs.d] applying ownership & permissions fixes...
svn-server | [fix-attrs.d] 01-resolver-resolv: applying...
svn-server | [fix-attrs.d] 01-resolver-resolv: exited 0.
创建代码仓库
- 创建harmony文件夹作为仓库名 mkdir /deploy/sorts/svn/data/svn/harmony
- 进入svn容器初始化仓库 docker-compose exec svn sh svnadmin create /deploy/sorts/svn/data/svn/harmony
- 修改配置文件(容器里面) 3.1 修改svnserver.conf文件 vi /home/svn/harmony/conf/svnserver.conf 将 #anon-access = read #auth-access = write 改成 anon-access = none auth-access = write 将 #password-db = passwd #authz-db = authz 改成 password-db = passwd authz-db = authz 3.2 修改passwd文件 vi /home/svn/harmony/conf/passwd 添加账号密码,这里是测试账号密码 [users] test = 123456 其中 test为svn账号 123456为svn密码 3.3 修改authz文件 vi /home/svn/harmony/conf/authz 添加 [harmony:/] chench = rw 其中
- harmony为仓库名
- /为仓库根路径
- chench为允许的用户
- rw为允许的权限为可读可写
重新加载配置
- 创建完仓库后按ctrol+d退出容器
- 执行docker-compose restart svn重启容器
- 拉取harmony仓库到本地 ![image.png]
- 将代码复制到本地harmony文件夹
- 上传到远程仓库 svn commit svn update