Use docker to build version control system-SVN

  • About the author: A Linux operation and maintenance engineer, mainly sharing the learning process and problems encountered by himself. the

  • Motto: Do ​​your best when you choose, do your best when you act, have no complaints when you persist, and have no regrets when you end.

  • Personal public account: nine in the morning and twelve in the evening, everyone is welcome to leave a message and exchange.

  • Homepage: Nine in the morning and twelve in the evening​​​​​​


Get to know SVN

The full name of SVN is Subversion, which is a version control system. It is one of the most popular open source version control systems. As an open source version control system, Subversion manages data that changes over time. These data are placed in a central repository (Repository). The archive is much like a normal file server, but it remembers every file change. In this way, you can restore the file to an old version, or browse the change history of the file. Subversion is a general-purpose system that can be used to manage any type of file, including program source code.
SVN adopts the client/server system. Various versions of the project are stored on the server. Program developers will first obtain a copy of the latest version of the project from the server and copy it to the local machine. Then, on this basis, each Each developer can perform independent development work on their own client, and can submit new code to the server at any time. Of course, you can also obtain the latest code on the server through the update operation, so as to maintain consistency with the version used by other developers.
There are two types of SVN clients, one is Web-based WebSVN, and the other is client software represented by Tortoise SVN. The former needs the support of the Web server, and the latter requires the user to install the client locally, both of which have free open source software for use. SVN stores version data in two ways: BDB (a transaction-safe table type) and FSFS (a storage system that does not require a database). Because the BDB method may lock the data when the server is interrupted, the FSFS method is safer.

Advantage

1. storage

The SVN server not only has the advantages of CVS in data storage, such as information resource storage, it will form a resource tree structure, which is convenient for storage, and the data will generally not be lost, and it has its own characteristics. SVN solves the problem of not being able to read and write the same file at the same time through the relational database and binary storage method, and adds its own unique "zero or one" principle.

2. speed

Compared with people's original CVS, SVN has greatly improved in terms of speed operation. Because the SVN server only supports a small amount of information and resource transmission, compared with other systems, it supports offline mode more, thus avoiding network congestion.

3. Security

SVN is a technically more secure product that realizes the combination of system and control. On the one hand, the overall security functions of the system can be effectively distributed in the branch systems, thereby ensuring the normal operation of the branch systems, so that the branch systems can complement each other, and finally the overall security of the system can be guaranteed, and the ultimate pursuit can be achieved through the principle of balance. security purposes.

Environmental requirements

Like CVS, SVN is also a cross-platform software that supports most common operating systems. Such as Windows, Linux, etc.
This article mainly uses Linux as the construction environment.

build process

OS: CentOS Linux release 7.9.2009 (Core)
docker: Docker version 19.03.14, build 5eb3275
If you don't know how to install docker, you can check direct link

Find svn mirror

[root@localhost ~]# docker search svn
NAME                           DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
garethflowers/svn-server       A simple Subversion server, using `svnserve`.   81                                      [OK]
elleflorio/svn-server          Lightweight Docker container running an SVN ...   76                                      
krisdavison/svn-server         A pre-configured SVN source control server.     28                                      
svnedge/app                    SVN Edge Official Release Image                 20                                      
paulovsm/svn-server            Subversion + Apache + SVNAdmin                  10                                      
nbrun/svn-client               Old SVN clients to work with old svn reposit...   5                                       
ryandocker/svn2git             Docker wrapper around the svn2git tool.         4                                       
atlassian/fisheye              Fisheye: search, monitor, and track across S...   4                                       
jgsqware/svn-client            A Simple SVN client based on Alpine             3                                       [OK]
polinux/svn2git                svn2git in a docekr (Alpine)                    2                                       [OK]
aneesv/svn-client              Svn Client                                      2                                       [OK]
yodamad/svn2git                Tool to help migration from SVN to Gitlab       2                                       
ksaito1125/svn-resource-type   concourseのresource-typeです.  Subversionリ...         1                                       [OK]
vertigo/svn2git                A minimalist container to use the (awesome) ...   1                                       [OK]
svnovikov/test                                                                 0                                       
svnedge/devbuild               SVN Edge Development Build                      0                                       
takanomasaki/svn-resource                                                      0                                       
timimages/svn                                                                  0                                       
svnbadrinath/hello_world                                                       0                                       
marouen13/svn-mar              an svn image                                    0                                       
0urob0r0s/svndaemon            Container agent for a simple, repo-based con...   0                                       
yukinagae/svn-to-git                                                           0                                       [OK]
crazymax/svn2git-mirror        Mirror SVN repositories to Git periodically     0                                       
kurento/svn-client                                                             0                                       
cycletime/svn-test             SVN Server with Test Data         

Download garethflowers/svn-server

[root@localhost ~]# docker pull docker.io/garethflowers/svn-server
Using default tag: latest
latest: Pulling from garethflowers/svn-server
2408cc74d12b: Pull complete 
f454a8fbcebf: Pull complete 
3c76ba5eee8a: Pull complete 
Digest: sha256:e97746b18bf7eddbfc5024221212ceb18436addc59adc711a3b13f29fe0dce2a
Status: Downloaded newer image for garethflowers/svn-server:latest
docker.io/garethflowers/svn-server:latest

view images

[root@localhost ~]# docker images
REPOSITORY                               TAG                 IMAGE ID            CREATED             SIZE
garethflowers/svn-server                 latest              2a8481254cd2        6 months ago        14.7MB

Start the container

#First create the data storage directory of the host machine
[root@localhost ~]# mkdir /usr/local/data
docker run --restart always --name svn -d -v /usr/local/dev/svn/repo:/var/opt/svn -p 3690:3690 garethflowers/svn-server
#Start the container
[root@localhost ~]# docker run --restart always --name svn -d -v /usr/local/data/:/var/opt/svn -p 3690:3690 garethflowers/svn-server
8a9304411bf397bcadcbf965eace9ab3db7636480d7f83a87e3ae838e5b4e68f
  • --restart always: represents self-start
  • --name svn: represents the container name is svn
  • -d: background start
  • -v /usr/local/data/:/var/opt/svn: mount the data directory
  • -p 3690:3690: Map the internal 3690 of the container to the host 3690

view container

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS                   PORTS                                            NAMES
8a9304411bf3        garethflowers/svn-server                               "/usr/bin/svnserve -..."   2 minutes ago       Up 2 minutes (healthy)   0.0.0.0:3690->3690/tcp                           svn

Enter the container and configure it

login container

[root@localhost ~]# docker exec -it svn sh

Create a svn resource warehouse named test

/var/opt/svn # svnadmin create test

View directory structure

/var/opt/svn/test # ls /var/opt/svn/test/
README.txt  conf        db          format      hooks       locks

configuration modification

Enter the test resource warehouse just created

/var/opt/svn #  cd /var/opt/svn/test/conf
/var/opt/svn/test/conf # 

Basic configuration modification

/var/opt/svn/test/conf # vi svnserve.conf
/var/opt/svn/test/conf # cat svnserve.conf |grep -rn -v ^#

19:anon-access = none
20:auth-access = write
27:password-db = passwd
36:authz-db = authz
52:realm = test

#Detailed configuration
anon-access = none             # Anonymous users cannot read and write, and can also be set to read-only read
auth-access = write            # writable by authorized users
password-db = passwd           # Password file path, relative to the current directory
authz-db = authz               # access control file
realm = /var/opt/svn/test       # The authentication namespace will be displayed on the authentication prompt interface and used as a keyword for the credential cache. You can write the warehouse name such as test

Permission file modification

password file modification

/var/opt/svn/test/conf # vi passwd
[users]
# harry = harryssecret
# sally = sallyssecret
admin = test123456

Authentication file modification

/var/opt/svn/test/conf # vi authz
[groups]
admin = admin   #The front is the user group admin, and the back of = is the user admin

[test:/]
@admin = rw  #Indicates that the test root directory has read and write permissions

[test:/test1]
@admin = rw  #Indicates that there is read and write permission for test1 in the test directory

Restart the container

/var/opt/svn/test # exit
[root@localhost ~]# docker restart svn
svn

Install client test

Windows authentication

tortoisesvn official website: https://tortoisesvn.net/downloads.html



custom file path


Enter the set account password

Liunx verification

install svn tools

[root@localhost ~]# yum -y install svn

View resource repository

[root@localhost ~]# svn checkout svn://192.168.6.231:3690/test/test1
Authentication realm: <svn://192.168.6.231:3690> test
Password for 'root': 
Authentication realm: <svn://192.168.6.231:3690> test
Username: admin
Password for 'admin': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://192.168.6.231:3690> test

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
Checked out revision 1.

Code words are not easy. If the article is hopeful for you, please support it three times.
If you have any questions, please leave a message and discuss together, thank you.
You can also pay attention to the official account below, and will reply as soon as possible after seeing the message.

Tags: Docker server svn

Posted by thorpe on Tue, 17 Jan 2023 18:01:21 +1030