Server :
- Install Openjdk 11 Headless (apt install openjdk-11-jdk-headless)
- Install Jenkins (see: https://www.jenkins.io/doc/book/installing/linux/)
open -> ipadresss:8080
cmd : cat /var/lib/jenkins/secrets/initialAdminPassword
- Install Nginx (configuration ip address jenkins to domain name)
config path : nano /etc/nginx/sites-available/default
- Install Docker
- Login account, use cmd : docker login registry.gitlab.com (see : https://docs.gitlab.com/ee/user/packages/container_registry/authenticate_with_container_registry.html)
** warning : you dont install docker-compose before login registry gitlab!
- Test create TASK on jenkins
see example picture below
configure source (GIT)
if you have add account, click add -> jenkins.
you dont change2 combo box, default value is good
after that, select your account
check list on build trigger, token value is dummy (free text)
set in curl gitlab.ci.yml :
curl --user admin:$JENKINS_PWD http://domain.jenkins.com:8080/job/dotnet-mvc/build?token=tokenbebasaja
JENKINS_PWD : password account jenkins
JENKINS_REPO : is token dummy (free text)
build command :
sudo docker login registry.gitlab.com -u salimsea -p glpatx-_U-YSY_pcdJ2TjCC9PWz
sudo docker pull registry.gitlab.com/salimsea/dotnet-mvc-demo:latest
sudo docker remove -f dotnet-mvc
sudo docker run -dt -p 5000:5000 --rm --name dotnet-mvc registry.gitlab.com/salimsea/dotnet-mvc-demo:latest
**info -> -p glpatx-_U-YSY_pcdJ2TjCC9PWz : personal token (edit profile) (check all rules)
- check permission PASWD jenkins(visudo nopasswd)
cmd : jenkins ALL=(ALL) NOPASSWD: ALL
- check this .gitlab-ci.yml
- if you want use webhook gitlab
go to sertting -> manage user
configure -> API token (save this token)
go to gitlab project
- dockerfile publish dotnet 5.0
==========
tutor deploy use two branch
1. primary branch use main or master
2. create new branch for production (cmd : git branch -m production)
3. git checkout production -> git pull origin main -> git push origin production
==========
refrence :
https://faun.pub/building-a-docker-image-with-gitlab-ci-and-net-core-8f59681a86c4
https://www.youtube.com/watch?v=P4pKnbcVRb8&t=380s
https://www.youtube.com/watch?v=T1Y-tr081EE
Tidak ada komentar:
Posting Komentar