Docker image for artifactory web server.
Container runs as non-root user. This user owns artifactory process and owns artifactory files.
To run container next volumes should be mapped:
- folder for SQL database
- folder for artifactory files
- folders for security files
- logs folder
- backups folder
- Pull docker image.
- Create user and group to own artifactory files and to run docker container:
sudo groupadd -g 966 artifactory
useradd -u 966 -g 966 -M artifactory
- Proceed to configuration.
- Pull project sources from version control system.
- Create user and group to own artifactory files and to run docker container:
sudo useradd -r artifactory
- Make build executable:
sudo chmod u+x ./build
- Execute build:
sudo ./build artifactory
- Proceed to configuration.
- Create folders for artifactory files:
sudo mkdir /artifactory
sudo mkdir /artifactory/db
sudo mkdir /artifactory/data
sudo mkdir /artifactory/security
- Create folder for logs:
sudo mkdir /var/log/artifactory
- Create folder for backups:
sudo mkdir /var/backups/artifactory
- Grant permit to all folders:
sudo chown -R artifactory:artifactory /artifactory
sudo chown artifactory:artifactory /var/log/artifactory
sudo chown artifactory:artifactory /var/backups/artifactory
- Copy etc/init.d/artifactory to /etc/init.d folder:
sudo cp ./etc/init.d/artifactory /etc/init.d
- Copy usr/sbin/artifactory to /usr/sbin folder:
sudo cp ./usr/sbin/artifactory /usr/sbin
- Copy usr/bin/artutil to /usr/bin folder:
sudo cp ./usr/bin/artutil /usr/bin
- Make all files executable:
sudo chmod a+x /etc/init.d/artifactory
sudo chmod a+x /usr/sbin/artifactory
sudo chmod a+x /usr/bin/artutil
- Register service:
sudo update-rc.d artifactory defaults
- Specify database root password in /usr/sbin/artifactory file:
docker run ... -e DB_ROOT_PASSWORD="<some_password>" ...
- Specify artifactory database user password in /usr/sbin/artifactory file:
docker run ... -e DB_USER_PASSWORD="<some_password>" ...
- Start artifactory service:
sudo service artifactory start
- Initialize artifactory database:
sudo artutil initialize
- Wait for some time, if artifactory is not loaded, then restart artifactory service:
sudo service artifactory restart
sudo service artifactory (start|stop|status|restart)
sudo artutil backup <filename>
Backup file /var/backups/artifactory/<filename>.tar.gz will be created.
sudo artutil restore <filename>
sudo artutil bash
Artifactory 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/artifactory.conf to /etc/apache2/sites-available folder:
sudo cp ./etc/apache2/sites-available/artifactory.conf /etc/apache2/sites-available
- Enable apache sites:
sudo a2ensite artifactory
- Restart apache service:
sudo service apache2 restart
- Stop artifactory service:
sudo service artifactory stop
- Specify new database root password in /usr/sbin/artifactory file:
docker run ... -e DB_ROOT_PASSWORD="<new_password>" ...
- Start artifactory service:
sudo service artifactory start
- Run the following command:
sudo artutil changeRootPassword "<old_password>"
- Stop artifactory service:
sudo service artifactory stop
- Specify new artifactory database user password in /usr/sbin/artifactory file:
docker run ... -e DB_USER_PASSWORD="<new_password>" ...
- Start artifactory service:
sudo service artifactory start
- Run the following command
sudo artutil changeUserPassword
Special characters should be escaped:
docker run ... -e DB_ROOT_PASSWORD="pa\$\$word" ...
docker run ... -e DB_USER_PASSWORD="pas\$11" ...
sudo crontab -l | { cat; echo "minute hour * * * /usr/bin/artutil backup <filename>"; echo ""; } | sudo crontab -
If you find my code useful, you can bye me a coffee