This project is not maintained anymore and is abandoned. Feel free to fork and make your own changes if needed.
🐳 Docker image to mirror SVN repositories to Git periodically based on Alpine and svn2git.
If you are interested, check out my other 🐳 Docker images!
💡 Want to be notified of new releases? Check out 🔔 Diun (Docker Image Update Notifier) project!
You can mirror multi SVN repositories through a configuration file (see below). When a repository is initialized, a SSH key is created. You will then only have to add the public key id_rsa.pub
on the remote Git server to make the synchronization work. The volume /data
is mounted to persist SSH keys and repositories.
Following platforms for this image are available:
$ docker run --rm mplatform/mquery crazymax/svn2git-mirror:latest
Image: crazymax/svn2git-mirror:latest
* Manifest List: Yes
* Supported platforms:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
- linux/386
- linux/ppc64le
- linux/s390x
TZ
: Timezone assigned to the container (defaultUTC
)PUID
: svn2git-mirror user id (default1000
)PGID
: svn2git-mirror group id (default1000
)
/data
: Contains SSH keys and repositories
This docker image works through a simple config.json file :
- id : The name of the repository for example without special chars and spaces. MUST BE UNIQUE.
- cron : Cron expression.
- svn2git.repo : SVN repo uri.
- svn2git.username : SVN repo username.
- svn2git.password : SVN repo password.
- svn2git.options : Options you can pass to svn2git on init.
- git.user : Git server user (git).
- git.repo : Git repo to mirror with.
- git.hostname : Git server hostname.
- git.port : Git server SSH port.
- authors : List of authors to convert from SVN to Git format. More info here.
In the following example, trunk, branches and tags of SVN repository https://svn.code.sf.net/p/ant-contrib/code/
will be synchronize with Git repository github.com/crazy-max/ant-contrib
every 15 minutes and some authors will be converted.
[
{
"id": "ant-contrib",
"cron": "*/15 * * * *",
"svn2git": {
"repo": "https://svn.code.sf.net/p/ant-contrib/code/",
"username": "",
"password": "",
"options": "--trunk ant-contrib/trunk --branches ant-contrib/branches --tags ant-contrib/tags"
},
"git": {
"user": "git",
"hostname": "github.com",
"port": 22,
"repo": "crazy-max/ant-contrib"
},
"authors": [
{
"svn": "bodewig",
"git": "Stefan Bodewig <stefan.bodewig@freenet.de>"
},
{
"svn": "carnold",
"git": "carnold <carnold@apache.org>"
}
]
}
]
⚠️ You have to create the configuration fileconfig.json
before running the container. See below.
Docker compose is the recommended way to run this image. You can use the following docker compose template, then run the container :
$ docker-compose up -d
$ docker-compose logs -f
You can also use the following minimal command :
$ docker run -d --name svn2git-mirror \
-e TZ="Europe/Paris" \
-v "$(pwd)/data:/data" \
-v "$(pwd)/config.json:/etc/svn2git-mirror/config.json" \
crazymax/svn2git-mirror:latest
If you need a jump start on figuring out what users made changes in your svn repositories, you can use the following command based on the example below :
$ docker-compose exec svn2git_mirror svn_authors <id>
bodewig
carnold
darius42
deanhiller
jonkri
mattinger
peterkittreilly
slip_stream
Replace
<id>
to match an existing one inconfig.json
.
To retrieve the SSH public key id_rsa.pub
to make the synchronization work on your Git server, enter the following command :
$ docker-compose exec svn2git_mirror git_pubkey <id>
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf5hIKe5v0TNdciiVBQRImyE3NtOuOw/q0arJOWT8OrVw9w/kYWIT02QGRDHNxczY5np512/zGXfIbXG/oo4sRdN38Q69sGVkpI6sBAXYNfBPFHYDgShu/pOGAg+jVOwJnKvq94HiXNL6CbCsyEwxWScG1FcK5VPNv0njqxmMq9lqgEAZvrbuBzGT4MrOMdTBuOdAqzDDALzCDngKV4O0Rr7q/9SUSUOvgOgRoULH+Dgt4KJObtit3xhsPWMvqN0OvxziGdwJW1H2wmsmIvxaQbSZfgwR/qAnicXBvHovLrgfXJnf1WFxDjJsnP+ORQ4XbdYieWxz70JMzphLnKhkT root@a7d42ca39fc2
Replace
<id>
to match an existing one inconfig.json
.
To mirror with a Github repository, you have to use a deploy key on the target Github repository :
Do not forget to check Allow write access.
All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬 You can also support this project by becoming a sponsor on GitHub 👏 or by making a Paypal donation to ensure this journey continues indefinitely! 🚀
Thanks again for your support, it is much appreciated! 🙏
MIT. See LICENSE
for more details.