Add new server to GitLab AutoDeploy: Difference between revisions

Add new server to GitLab AutoDeploy - added content
(Created page with "If not mentioned otherwise, the following values are variables and will change from project to project (or server to server):")
 
(Add new server to GitLab AutoDeploy - added content)
Line 1: Line 1:
If not mentioned otherwise, the following values are variables and will change from project to project (or server to server):
If not mentioned otherwise, the following values are variables and will change from project to project (or server to server):
* dev-server - Git branch name, usually following the name of the server which the files will be deployed to (can be uat-server or live-server, etc)
* the /var/www/html path is just an example, this will be the root folder of the website we want to deploy to (from nginx/apache sites-enabled)
* the <nowiki>https://gitlab.apoyar.eu/somepath</nowiki> will be the url to the project in question - to be obtained from GitLab
==== And now the steps: ====
* Install Git AutoDeploy
** apt-get install software-properties-common
** add-apt-repository ppa:olipo186/git-auto-deploy
** apt-get update
** apt-get install git-auto-deploy
* copy the settings file from Dev: /etc/git-auto-deploy.conf.json
* amend the file contents: url to access (GitLab project), active branch required
* open the /etc/init.d/git-auto-deploy file and make the daemon running as www-data:
** DAEMON_UID="www-data"
** DAEMON_GID="www-data"
* Run systemctl daemon-reload after you’ve made the changes above
* A reboot may be required here
* Make sure the Deploy Bot account has access to the project and is made a Master
* Backup the current website contents: cp -R /var/www/html/ /home/neal/backup/
* Delete the website contents, including the git part (if present):
** cd /var/www/html
** rm –rf *
** rm –rf .git .gitignore .htaccess
* Start the daemon in foreground, but as the user www-data: sudo -H -u www-data bash -c 'git-auto-deploy --pid-file /var/run/git-auto-deploy/git-auto-deploy.pid --log-file /var/log/git-auto-deploy.log --config /etc/git-auto-deploy.conf.json'
* Once static, Ctrl-C the process
* It should create the tree
* Check the contents of the /var/www/html/.gitignore file
* If not present, create one, own it by www-data and push back to the server. If present, leave out the 3 next steps
** vi .gitignore
** chown www-data:www-data .gitignore
** git push origin dev-server
* Copy the ignored files listed above from backup
* Clear the cache and push changes to GitLab:
** cd /var/www/html
** git rm –rf –cached .
** git add .
** git status
** if the above command says nothing to commit, you can leave out the 2 next steps
** git commit
** git push origin dev-server
* Make sure all objects in the .git/objects folder are owned by www-data: chown –R www-data:www-data *
* Change the Deploy Bot to be a Reporter in GitLab
* Start the service: service git-auto-deploy start
* Observe the log file: tail –f /var/log/git-auto-deploy.log
* If you don’t see anything in the log and the foreground app runs fine, reboot the server
* Add the <nowiki>http://hostname:8001</nowiki> as webhook to GitLab project in question: <nowiki>https://gitlab.apoyar.eu/root/bleckmann/settings/integrations</nowiki>
* Reboot the server and check whether it’s listening on port 8001: netstat -anp
Anonymous user