Docker image for PyPI caching web server.
Container runs as non-root user. This user owns DevPI process and owns DevPI files.
To run container next volumes should be mapped:
- folder for DevPI files
- logs folder
- backups folder
-
Pull docker image.
-
Create user and group to own DevPI files and to run docker container:
sudo groupadd -g 963 devpi
useradd -u 963 -g 963 -M devpi
-
Proceed to configuration.
-
Pull project sources from version control system.
-
Create user and group to own DevPI files and to run docker container:
sudo useradd -r devpi
-
Make build executable:
sudo chmod u+x ./build
-
Execute build:
sudo ./build devpi
-
Proceed to configuration.
-
Create folders for DevPI files:
sudo mkdir /devpi
sudo mkdir /devpi/data
-
Create folder for logs:
sudo mkdir /var/log/devpi
-
Create folder for backups:
sudo mkdir /var/backups/devpi
-
Grant permit to all folders:
sudo chown -R devpi:devpi /devpi
sudo chown devpi:devpi /var/log/devpi
sudo chown devpi:devpi /var/backups/devpi
-
Copy etc/init.d/devpi to /etc/init.d folder:
sudo cp ./etc/init.d/devpi /etc/init.d
-
Copy usr/sbin/devpi to /usr/sbin folder:
sudo cp ./usr/sbin/devpi /usr/sbin
-
Copy usr/bin/dputil to /usr/bin folder:
sudo cp ./usr/bin/dputil /usr/bin
-
Make all files executable:
sudo chmod a+x /etc/init.d/devpi
sudo chmod a+x /usr/sbin/devpi
sudo chmod a+x /usr/bin/dputil
-
Register service:
sudo update-rc.d devpi defaults
-
Start DevPI service:
sudo service devpi start
-
Create file ~/.pip/pip.conf (Linux) or %APPDATA%\pip\pip.ini (Windows).
-
Specify pip index URL in this file:
[global] index-url = http://server/devpi/root/pypi/+simple/ trusted-host = server
where server is DevPi server's name or IP.
sudo service devpi (start|stop|status|restart)
sudo dputil devpi <arguments>
devpi command is passed to the running docker container with dputil utility.
sudo dputil backup <filename>
Backup file /var/backups/devpi/<filename>.tar.gz will be created.
sudo dputil restore <filename>
sudo dputil bash
DevPI 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.
-
Enable apache mod_proxy:
sudo a2enmod deflate headers proxy proxy_ajp proxy_balancer proxy_connect proxy_html proxy_http rewrite
-
Configure proxy:
<VirtualHost *:80> ... ProxyPreserveHost On <Proxy *> Order allow,deny Allow from all </Proxy> ... </VirtualHost>
-
Copy ./etc/apache2/sites-available/devpi.conf to /etc/apache2/sites-available folder:
sudo cp ./etc/apache2/sites-available/devpi.conf /etc/apache2/sites-available
-
Enable apache sites:
sudo a2ensite devpi
-
Restart apache service:
sudo service apache2 restart
-
Specify the server to use:
sudo dputil devpi use http://localhost:3141
-
Connect to the server:
sudo dputil devpi login root
The default root password is empty (simply press Enter).
-
Create user:
sudo dputil devpi user -c packages email=packaging@company.com password=packages
-
Verify that user is created:
sudo dputil devpi user -l
-
Create stable index:
sudo dputil devpi index -c packages/stable bases=root/pypi volatile=False
-
Create staging index:
sudo dputil devpi index -c packages/staging bases=packages/stable volatile=True
sudo crontab -l | { cat; echo "minute hour * * * /usr/bin/dputil backup <filename>"; echo ""; } | sudo crontab -
If you find my code useful, you can bye me a coffee