Thursday, January 4, 2024

how to Deploying ReactJS Docker Container Via jenkins

 

In this task we are using the same machine for the Jenkins and the Deployment Host.

 

Prerequisites:

Git (With Public Repository)
Java-17
Jenkins
Docker
Docker-Compose
Permission : (sudo usermod -a -G docker jenkins and sudo usermod -aG docker $USER)

1) In Git Configure React Fresh Code and Add (Dockerfile/docker-compose.yml/Jenkinsfile)

https://github.com/subhashsautiyal/jenkins-docker-1.git

2) In Jenkins Create Credential for Docker hub.

a) Manage Jenkins >> Credential >> Create Global Credential
b) Write DockerHub username and passward
c) In ID : write dockerHub and In Description : write "This Credential Is Using For DockerHub"

3) In Jenkins Create pipeline and follow the below steps.

a) Write the name and Select "Pipeline" than Ok
b) Select the GitHub project and paste git project URL "https://github.com/subhashsautiyal/jenkins-docker-1"
c) Select "GitHub hook trigger for GITScm polling"
d) In Definition : Select "Pipeline Script From SCM"
e) In SCM : Select "Git"
f) Paste Git Repository URL : "https://github.com/subhashsautiyal/jenkins-docker-1.git"
g) Select Git Branch Name : "*/main"
h) Select Script Path : "Jenkinsfile" which is the file stored in git
i) Save and Click on build now

4) Build the pipeline and monitor the steps

Finally You have deployed the container ! 


In this task we are using the Different Machine for the jenkins and the Deployment Host.


Prerequiets:

Git (With Public Reposiotory)
Java-17
Jenkins
Docker
Docker-Compose
Permission : (sudo usermod -a -G docker jenkins/sudo usermod -aG docker $USER)

1) In Git Configure : Setup React Fresh Code and Add (Dockerfile/docker-compose.yml/Jenkinsfile)

https://github.com/subhashsautiyal/jenkins-docker-2.git

2) In Jenkins Create Credential for Dockerhub and Remote Host(Node).

a) Manage Jenkins >> Credential >> Create Global Credential
b) Write DockerHub username and passward
c) In ID : write "dockerHub" and In Description : write "This Credential Is Using For DockerHub"

a) Manage Jenkins >> Credential >> Create Global Credential
b) Write Node username and passward
c) In ID : write "react-server-credential" and In Description : write "This Credential Is Using For React-Server"

a) Manage Jenkins >> Nodes >> New node >> Write Name : React-Server >> Permanent Agent >> Create
b) Remote root directory : /home/ubuntu/
c) Lables : "React-Server"
d) Launch method : "Launch Agent Via SSH"
e) Host : "Server-IP-Address"
f) Credential : Select "react-server-credential"
g) Host Key Verification Strategy : Select "Manually Trusted Key Verification Stratagy"
h) Save

3) In Jenkins Create pipeline and follow the below steps.

a) Write the name and Select "Pipeline" than Ok
b) Select the GitHub project and paste git project URL "https://github.com/subhashsautiyal/jenkins-docker-2"
c) Select "GitHub hook trigger for GITScm polling"
d) In Definition : Select "Pipeline Script From SCM"
e) In SCM : Select "Git"
f) Paste Git Repository URL : "https://github.com/subhashsautiyal/jenkins-docker-1.git"
g) Select Git Branch Name : "*/main"
h) Select Script Path : "Jenkinsfile" which is the file stored in git
i) Save and Click on build now

4) Build the pipeline and monitor the steps

Finally You have deployed the container !

No comments:

Post a Comment

testing