Sign inSign up

dshap/mercurial

By dshap

Updated 15 days ago

Docker image for mercurial web server

Image
Web servers
Content management system
0

1.0K

dshap/mercurial repository overview

Mercurial web server

Docker image for mercurial web server.

Container runs as non-root user. This user owns mercurial process and owns mercurial files.

To run container next volumes should be mapped:

  • folder for mercurial files
  • logs folder
  • backups folder

Installation

Installation from docker image
  1. Pull docker image
  2. Create user and group to own mercurial files and to run docker container:
    sudo groupadd -g 1199 mercurial
    
    useradd -u 1199 -g 1199 -M mercurial
    
  3. Proceed to configuration
Installation from source
  1. Pull project sources from version control system
  2. Create user and group to own mercurial files and to run docker container:
    sudo useradd -r mercurial
    
    sudo groupmod -g 1199 mercurial
    
    sudo usermod -u 1199 mercurial
    
  3. Make build executable:
    sudo chmod u+x ./build
    
  4. Execute build:
    sudo ./build mercurial
    
  5. Proceed to configuration
Configuration
  1. Obtain configuration files and scripts from the container:
    cd ~
    
    mkdir conf
    
    sudo chown mercurial:mercurial ~/conf
    
    sudo docker run \
        --rm \
        -v ~/conf:/export \
        dshap/mercurial:6.3.2 export-assets
    
  2. Create folders for mercurial files:
    sudo mkdir /mercurial
    
    sudo mkdir /mercurial/repositories
    
    sudo chown -R mercurial:mercurial /mercurial
    
  3. Create a folder for logs:
    sudo mkdir /var/log/mercurial
    
    sudo chown -R mercurial:mercurial /var/log/mercurial
    
  4. Create a folder for backups:
    sudo mkdir /var/backups/mercurial
    
    sudo chown -R mercurial:mercurial /var/backups/mercurial
    
  5. Copy service configuration file:
    sudo cp ~/conf/etc/init.d/mercurial /etc/init.d
    
    sudo chmod a+x /etc/init.d/mercurial
    
  6. Copy docker run script:
    sudo cp ~/conf/usr/sbin/mercurial /usr/sbin
    
    sudo chmod a+x /usr/sbin/mercurial
    
  7. Copy util script:
    sudo cp ~/conf/usr/bin/mutil /usr/bin
    
    sudo chmod a+x /usr/bin/mutil
    
  8. Remove temporary config folder:
    sudo rm -rf ~/conf
    
  9. Register service:
    sudo update-rc.d mercurial defaults
    
  10. Start mercurial service:
    sudo service mercurial start
    

Management

Service management
sudo service mercurial (start|stop|status|restart)
User management

Users are managed with the madmin web interface. The default login/password is admin/admin.

Repository management
sudo mutil hg <command> <arguments>

hg command is passed to the running docker container with mutil utility.

If command needs a path to the repository, this path is specified like this:

PATH=/repopath/reponame
Create backup
sudo mutil backup <filename>

Backup file /var/backups/mercurial/<filename>.tar.gz will be created.

Restore backup
sudo mutil restore <filename>
Command line (bash)
sudo mutil bash

Apache mod_proxy configuration

Mercurial web server can be located with another web applications. For example, mercurial, bugzilla, wiki etc can be run as docker containers on the same host. In this case apache server can be used to redirect requests to different docker containers.

  1. Enable apache mod_proxy:
    sudo a2enmod deflate headers proxy proxy_ajp proxy_balancer proxy_connect proxy_html proxy_http rewrite
    
  2. Configure proxy:
    <VirtualHost *:80>
        ...
        ProxyPreserveHost On
        <Proxy *>
            Order allow,deny
            Allow from all
        </Proxy>
        ...
    </VirtualHost>
    
  3. Copy site configuration file:
    sudo cp ~/conf/etc/apache2/sites-available/mercurial.conf /etc/apache2/sites-available
    
  4. Enable apache sites:
    sudo a2ensite mercurial
    
  5. Restart apache service:
    sudo service apache2 restart
    

HOW TO

How to create a new repository
sudo mutil hg init PATH=/newreponame
sudo mutil hg init PATH=/newrepopath/newreponame
How to change repository description

Edit contact and description fields in /mercurial/repositories/repopath/reponame/.hg/hgrc file:

[web]
...
contact         = Repository contact person
description     = Repository description
...
How to restrict access to repository

Edit allow_read and allow_push fields in /mercurial/repositories/repopath/reponame/.hg/hgrc file:

[web]
...
allow_read      = *
allow_push      = username
...
How to change default theme

Specify WEB_STYLE environment variable in /usr/sbin/mercurial file:

docker run ... -e WEB_STYLE="gitweb" ...

Available themes are:

  • paper (default theme)
  • coal
  • spartan
  • monoblue
  • gitweb
How to disable multi-level directory hierarchy

Specify WEB_COLLAPSE environment variable in /usr/sbin/mercurial file:

docker run ... -e WEB_COLLAPSE="false" ...
How to change admin password
  1. Login to madmin web interface
  2. Open Admin Password page
  3. Specify a new password and create hash
  4. Specify this hash in /usr/sbin/mercurial file:
    docker run ... -e MADMIN_USER_PASS="<hash>" ...
    
  5. Restart mercurial service:
    sudo service mercurial restart
    
How to configure reset email

Specify the following variables in /usr/sbin/mercurial file:

  • MADMIN_MAIL_SERVER
  • MADMIN_MAIL_USER_NAME
  • MADMIN_MAIL_USER_PASS
  • MADMIN_MAIL_FROM
How to create cron job for backups
sudo crontab -l | { cat; echo "minute hour * * * /usr/bin/mutil backup <filename>"; echo ""; } | sudo crontab -

Tag summary

Content type

Image

Digest

Size

301.2 MB

Last updated

about 5 years ago

docker pull dshap/mercurial