elleFlorio / svn-docker

Lightweight Docker image to build a container running an SVN server
MIT License
145 stars 106 forks source link

Configuration persistence #30

Closed layanto closed 3 years ago

layanto commented 3 years ago

Where does this docker image store the configuration data? I have done -v <hostpath>:/home/svn but I think this is only to persist the SVN repositories.

After setting up username and password via docker exec -t svn-server htpasswd -b /etc/subversion/passwd <username> <password>

If I then recreate the container (e.g. new image version, etc), all configurations appear to have been lost. I can no longer login with user set above.

elleFlorio commented 3 years ago

Hello,

Yes, the /home/svn is only for repositories. The user's credentials are saved in the /etc/subversion/passwd when the htpasswd command is executed. If you want to keep that you can try to mount that folder to a volume, but I believe there will be some permissions problems (the container is running as root). I am not sure how to solve that, probably you can try to fork the repo and change the Dockerfile to run with a different user. 🤔

layanto commented 3 years ago

Why not expose /etc/subversion/passwd as a volume and let user create htpasswd in the volume prior to starting the container?

layanto commented 3 years ago

Manually adding /etc/subversion volume (bind volume) works but I have to manually create passwd file and subversion-access-control file and have to make them writable to the container.

 docker exec -t svn-server chmod a+w /etc/subversion/subversion-access-control
 docker exec -t svn-server chmod a+w /etc/subversion/passwd
layanto commented 3 years ago

Where does SVNAdmin store its configuration? When I re-created the container (using the same repo volume and /etc/subversion volume), SVN user configuration persists but SVNAdmin configuration did not.

layanto commented 3 years ago

SVNAdmin stores its configuration in /opt/svnadmin/data/config.ini

This configuration is also not persisted.

layanto commented 3 years ago

Not sure how to modify the docker image to handle this properly, but this is what I did to workaround configuration persistence issue.

mkdir /home/jl/svn/config
mkdir /home/jl/svn/repo
mkdir/home/jl/svn/svnadmin
chmod a+w /home/jl/svn/repo
chmod a+w /home/jl/svn/svnadmin
touch /home/jl/svn/config/passwd
touch /home/jl/svn/config/subversion-access-control
chmod a+w /home/jl/svn/config/passwd
chmod a+w /home/jl/svn/config/subversion-access-control
vi /home/jl/svn/config/subversion-access-control

copy the content of subversion-access-control to /home/jl/svn/config/subversion-access-control

touch /home/jl/svn/svnadmin/.htaccess
vi /home/jl/svn/svnadmin/.htaccess

copy the content of SVNAdmin's data/.htaccess to /home/jl/svn/svnadmin/.htaccess

touch /home/jl/svn/svnadmin/config.tpl.ini
vi /home/jl/svn/svnadmin/config.tpl.ini

copy the content of SVNAdmin's data/config.tpl.ini to /home/jl/svn/svnadmin/config.tpl.ini

docker run -d --name svn-server -p 80:80 -p 3690:3690 -v /home/jl/svn/repo:/home/svn -v /home/jl/svn/config:/etc/subversion -v /home/jl/svn/svnadmin:/opt/svnadmin/data elleflorio/svn-server
docker exec -t svn-server htpasswd -b /etc/subversion/passwd <username> <password>
layanto commented 3 years ago

Will give it a go to fix this properly and raise a PR.

elleFlorio commented 3 years ago

Thank you @layanto! 🙏🏻