How to Deploy a React App on Docker with Jenkins and Docker Compose
1. Introduction
ááŽáá áşááąáŤááşáážáŹááąáŹáˇ React sample application áá áşááŻááᯠJenkins pipeline áá˛áˇ Docker compose áááŻááŻáśá¸ááźáŽá¸ Deploy ááŻááşááźáá˝áŹá¸áážáŹááŤá
2. Prerequisites
Jenkins installation
Jenkins installation ááŻááşááŹá¸áááŻáˇáááŻááŤáááşá Jenkins áá˛áˇááááşááááşá¸ááŽá¸ááąá¸áááşááąáŹáˇ Jenkins Jenkins master and agent installation and configuration áááŻáĄáááşá ááşá¸ááźááˇáşáááŻáˇáĄááźáśááźáŻááŤáá áąá
Jenkins master and agent installation and configuration: Part 01
https://burmesebytes.hashnode.dev/install-and-configure-jenkins-master-and-jenkins-agent-via-ssh-part-01Jenkins master and agent installation and configuration: Part 02
https://burmesebytes.hashnode.dev/install-and-configure-jenkins-master-and-jenkins-agent-via-ssh-part-02Docker and Docker-Compose Installation:
Jenkins Agent áážáŹ Docker and Docker compose ááᯠinstall ááŻááşááŹá¸áááŻáˇáááŻááŤáááşáCreate a react sample app (use npm)
ááźáŽá¸áááşááąáŹáˇ react sample app áá áşáᯠcreate ááŻááşáááŤáááşá
Create a GitHub repo for source code (SCM)
application áááźáŽáááŻáááş source code áá˝áąááááşá¸áááŻáˇ GitHub repository áá áşáᯠCreate ááŻááşáááŤáááşá
3. Docker and Docker Compose installation
Jenkins master and agent ready ááźá áşááźáŽáááŻáááşááąáŹáˇ Jenkins agent áážáŹ Docker Engine ááᯠá ááźáŽá¸ Install ááŻááşááŤáááşá
Docker apt source ááᯠadd ááŤáááşá
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
apt source áĄáá˝ááş áááŻáĄááşááŹááźááşááźáŽá¸ add ááźáŽá¸áá˝áŹá¸ááźáŽáááŻáááşááąáŹáˇ Docker ááᯠInstall á ááŻááşáááŻáˇáááŤááźáŽá áĄáąáŹááş á Command ááąá¸áĄáááŻááşá¸ áááŻáĄááşáá˛áˇ Docker Components áá˝áą áĄááŻááş Install ááŻááşáááŻááşááŤáááşá
Install the Docker packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Add your user to docker group
agent run áááşáˇ user ááᯠDocker Group áá˛ááᯠáááˇáşááŤáááşá ááźáŽá¸áááşááąáŹáˇ user ááᯠlogout/ login ááźááşááŻááşáááŻááşá፠Group update ááŻááşááŹá¸ááŹááᯠáĄáááşááźáąáá˝áŹá¸áĄáąáŹááşáááŻáˇááŤá
áĄáááşá user ááᯠlogout/login ááŻááşááŹááąáŹááş Docker run áááŻáˇ permission áááá˛áˇ error ááźááąáá˛áˇáááş agent host ááᯠstart ááťááźáŽá¸ááźááşá ááşá¸ááźááˇáşááŤá
ááŤáááąáŹáˇ Docker Group áá˛ááᯠagent user add áá˛áˇ Command ááŤá ááťá˝ááşááąáŹáşáááąáŹáˇ jenkins
áááŻáá˛áˇ user ááŻáśá¸ááŹá¸ááŤáááşá
sudo usermod -aG docker <your-user-name>
Check the docker info
ááźáŽá¸áááşááąáŹáˇ Docker install ááŻááşáᏠáĄáąáŹááşááźááşáá˛áˇááŹá¸ docker info command áá˛áˇááźááˇáşááźááˇáşáááŻááşááŤáááşá
docker info
Learn More about docker installation: https://docs.docker.com/engine/install/ubuntu/
4. Creating a react sample app (use npm)
Docker áááşá¸ áááźáŽáááŻááąáŹáˇ react application ááᯠáááşáážáááŻáśá¸ááąáá˛áˇ laptop áá˛áážáŹáᲠCreate ááŻááşááŤáááşá Developer's laptop áááŻáˇ áá°á áááŻááşááŤá áĄáááşááŻáśá¸ react app áá áşáᯠCreate áááŻááşáááş npm áá˛áˇ node js install ááŻááşááŹá¸áááŻáˇ áááŻááŤáááşá
Prerequisite for creating React app
- npm and node js >= version 14
ááŽáážáŹáááąáŹáˇááťá˝ááşááąáŹáş á WSL ááŻáśá¸ááŹá¸ááŹááááŻáˇ áĄáąáŹááşá step áá˝áąáĄáááŻááşá¸ Node JS 14 ááᯠinstall ááŻááşáááŻááşááŤáááşá WSL - (Ubuntu 22.04.2 LTS â Jammy Jellyfish).
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
command -v nvm
nvm install 14
nvm alias default 14
áááźáŹá¸ OS áá˝áąááźáąáŹááˇáş áĄáááşáááźáąááŹáážááááş ááŽáážáŹ ááźááˇáşááźáŽá¸ install ááŻááşáááŻááşááŤáááşá
Learn more about node js and npm installation
Install ááŻááşááźáŽá¸áá˝áŹá¸áááşááąáŹáˇ npm áá˛áˇ node js version áá˝áąááᯠááŽáááŻááşá¸á á áşááźááˇáşáááŻááşááŤáááşá
node -v
npm -v
npm version
installation step áá˝áąááźáŽá¸áá˝áŹá¸áááşááąáŹáˇ react sample app ááąá¸áá
áşáᯠá
ááźáŽá¸ Create ááŻááşááŤáááşá
Check for more > https://create-react-app.dev/docs/getting-started
npm init react-app react-jenkins-docker
Create ááŻááşááźáŽá¸áá˝áŹá¸áááşááąáŹáˇ React Application folder áá˛ááᯠáááşáááŻááşááźááˇáşáááŻááşááŤáApplication Source Code áá˝áąááąáŹááşááąááŹáááŻáá˝áąáˇáááŤááááˇáşáááşá
ááźáŽá¸áááşááąáŹáˇ npm install áá˛áˇ application áĄáá˝ááş áááŻáĄááşáá˛áˇ node packages áá˝áąáá˝ááşá¸ááŤáááşá
ááźáŽá¸áá˝áŹá¸áááşááąáŹáˇ npm start ááźááşáááŻááşááŤá
cd react-jenkins-docker
npm install
npm start
npm start áááŻááşááźáŽáááŻááŹáá˛áˇ Default port number 3000 áážáŹ react app ááąá¸á run ááąááŤááááˇáşáááş browser áááą localhost:3000 áá˛áˇááąáŤáşááźááˇáşáááŻááşááŤáááşá
For example: http://localhost:3000/
Learn more other react Example Projects:
https://legacy.reactjs.org/community/examples.html
5. Creating a GitHub repo for source code (SCM)
Application áááźáŽáááŻáááşááąáŹáˇ Application Source Code áá˝áąááááşá¸áááŻáˇ GitHub repository áá áşáᯠCreate ááŻááşááŤáááşá GitHub áĄááąáŹááˇáşáážáááŹá¸áááŻáˇáááŻááŤáááşá
Prerequisites for creating a GitHub repo:
GitHub Account
Basic understanding of Git and GitHub
git áá˛áˇááááş familiar ááááşáááźá
áşááąá¸áá°á¸áááŻáááşááąáŹáˇ git áá˛áˇáááşáááşááźáŽá¸ááŽáážáŹáá˝áŹá¸ááźááˇáşáááŻááşááŤáááşá
https://www.w3schools.com/git/git_intro.asp?remote=github
Repo áĄáá áşáá áşáᯠCreate ááŻááşáááŻáˇ New repository ááᯠáážáááşáááŻááşááŤá
Create a git repo > Go to your github account
ááźáŽá¸áááş Repo Name ááąá¸áááŻááşááŤá Private repo áᲠááŹá¸ááŤáááşá
ááźáŽá¸áááşááąáŹáˇ React app create ááŻááşáá˛áˇáá˛áˇ project directory áá˛ááźááşáá˝áŹá¸áááŻááşááŤá ááźáŽá¸áááşááąáŹáˇ áĄáááşáážáááźáŽá¸ááŹá¸ .git
áááŻáá˛áˇáááŻááşáááŻááťááşáááŻááşááŤáááşá repo áĄáá
áşáá
áşáᯠáĄááąáá˛áˇ git init
ááᯠrun áááŻááşááŤá
rm -rf .git && git init
ááźáŽá¸áááşááąáŹáˇ Laptop áá˛áážáŹ áážááá˛áˇ local repo áá˛áˇ GitHub ááąáŤáşáážáŹ áážááá˛áˇ remote repo áááŻáˇáááŻááťáááşáááşááŤáááşá ááťáááşáááşáááŻáˇáĄáá˝ááş GitHub repo ááᯠlaptop áááą access ááááŻáˇáááŻááŤáááşá Authorize áážááááŻáˇáááŻááŤáááş ááťá˝ááşááąáŹáşáááąáŹáˇááŽááąááŹáážáŹ SSH áááŻáᲠááŻáśá¸ááŤáááşá
ááŽáážáŹ ááźááˇáşáááŻáˇáááŤáááşá
áĄáááşááŻáśá¸ ssh-keygen
áá˛áˇ Key pair áá
áşáᯠCreate ááŻááşááŤá ssh-keygen
áááŻááźáŽá¸ generate ááŻááşáááŻáˇ áááŹáá˛áˇ ~/.ssh/id_rsa.pub
áááŻáá˛áˇ public key ááᯠGitHub ááŽááąááŹáážáŹ áá˝áŹá¸áááˇáşáááŻááşáááşáááŤááźáŽá
repo ááŽááᯠpush ááŻááşáážáŹ ááááŻáˇ áĄáąáŹááşá Allow write access ááᯠáĄáážááşááźá áşááąá¸áá˛áˇáááŻáˇáááŻááŤáááşá
á áŹáĄáááşá¸áážááşáá˝áŹá¸áážáŹá ááŻá¸áááŻáˇ ááŽáĄáááˇáşáááŻáĄááťáŹá¸ááźáŽá¸áááźáąáŹááąáŹáˇááŤáá°á¸ááĄáááşáááźáąááŹáážááááş Burmese Bytes áá˛áˇ Communication channel áá áşááŻááŻáááą ááŹááąá¸áááŻáˇáááŤáááşá GitHub áá˛áˇ ááťáááşááźáŽá¸ááŹá¸áá°áá˝áąáááąáŹáˇ https method ááᯠáááşá¸ááŻáśá¸áááşá¸áááŤáááşá
áĄááŻááą remote SSH URL copy áá°áááŻááşááŤáááşá
Local repo áá˛áážáŹ remote repo áá˛áˇ ááťáááşáááŻáˇ add áááŻááşááŤáááşá Add ááźáŽá¸áááşááąáŹáˇ git remote -v
áá˛áˇ ááźááşááźááˇáşáááŻáˇáááŤáááşá
git remote add origin git@github.com:wwwaiyan/react-jenkins-docker.git
git remote -v
ááźáŽá¸áááşááąáŹáˇ create ááŻááşáá˛áˇáá˛áˇ React application source code áá˝áąááᯠremote repo ááąáŤáşááᯠpush ááŻááşáááŻáˇ git staging áááŻáááŻáˇááŤáááşááźáŽá¸áááş commit ááŻááşááźáŽá¸ áááŤáááşá¸ remote repo áᎠáááşá¸ push áááŻááşááŤáááşá
git add .
git commit -m "first commit"
git push to GitHub remote repo
Note: Ensure you have write access to the GitHub repository.
git push origin master
Push ááŻááşááźáŽá¸áá˝áŹá¸ááźáŽáááŻáááşááąáŹáˇ GitHub remote repo áá˛áážáŹ Source Code áá˝áąááᯠáá˝áŹá¸á á áşááźááˇáşáááŻááşááŤáááşá
6. Creating a New Jenkins Pipeline
Application áááşá¸áááźáŽá¸ Source Code áá˝áą GitHub remote repo ááąáŤáşáááşá¸áááźáŽáááŻáááş Jenkins pipeline áááŻá ááźáŽá¸ Create ááŻááşááźááĄáąáŹááşá Jenkins áááą GitHub repo ááŽá Code áá˝áąááᯠáážááşá¸áá°áážáŹááááŻáˇ repo áááŻááąáŹáˇ Jenkins áááą Access ááááŻáˇ áááşáááŻááŤáááşá
Prerequisites for creating a Jenkins pipeline:
- GitHub repo access (SCM) from Jenkins
6.1 Generate SSH key pair for GitHub repo access form Jenkins
ááŽáážáŹáááşá¸ SSH method áááŻááŻáśá¸ááŤáááşá SSH Keypair áá áşáᯠGenerate ááŻááşááŤáááşá
ssh-keygen -C github-repo-ssh -f github-repo-ssh
6.2 Copy the public key to GitHub Repo
Generate ááŻááşááźáŽá¸áááşááąáŹáˇ Public Key ááᯠGitHub Repo áážáŹ áá˝áŹá¸áááˇáşáááŤáááşá
GitHub repo Settings áá˛á Deploy Keys áážáŹáááˇáşáááŻááşááŤá
Go to GitHub Repo Settings > Deploy keys > add deploy key
6.3 Copy Private Key to Jenkins Credential
Private Key áááŻááąáŹáˇ Jenkins Credential áĄááąáá˛áˇ Create ááŻááşááŤáááşá Security áĄáąáŹááşá Credentials áá˛áááŻáá˝áŹá¸áááŻááşááŤá
Go to Jenkins Console > Manage Jenkins > Go to Security tab > Credentials
Global áá˛áážáŹáᲠCreate ááŻááşááŤáááşá ááźáŽá¸áááşááąáŹáˇ Add Credentials
Click on global Domain > Add Credential
SSH Private áááŻááŻáśá¸áážáŹááźá áşáááŻáˇ
Credentials kind ááᯠSSH Username with private key
áááŻáˇáá˝áąá¸ááąá¸áááŻááşááŤá
Credentials kind > Select SSH Username with private key
Credential ID áááˇáşáááŻááşáááşáááŤááźáŽ username ááᯠááŽáážáŹ blank ááŹá¸áá˛áˇáááŻáˇáááŤáááşá
ááźáŽá¸áááşááąáŹáˇ áĄááŻá generate ááŻááşáá˛áˇáá˛áˇ SSH Private key ááᯠpaste ááŻááşááźáŽá¸áááş Save áááŻááşá፠á
áĄááŻáááŻáááş SSH Credential áážá áşááŻáá˝áąááŤááááˇáşáááşááá áá áşááŻáááąáŹáˇ agent áĄáá˝ááşááŻááşááŹá¸áá˛áˇ áá áşááŻááŤá
Pipeline Create áááŻááşáááşáážáŹ GitHub repo ááᯠssh áá˛áˇ access ááŻááşáážáŹ ááááŻáˇ Git Host Key No Verification ááᯠNo ááŹá¸áááŻááşááŤáááşá
notes: Git Host Key No Verification: not recommended for prod
Manage Jenkins áá˛á Security áĄáąáŹááşá Security áá˛ááᯠáááşáááŻááşááŤ
Manage Jenkins > Go to Security Tab > Security
áĄáąáŹááşááŻáśá¸áážáŹ Git Host Key Verification Configurations áááŻááźáŽá¸ áá˝áąáˇáááŤááááˇáşáááşá
No Verification áááŻáˇááŹá¸áááŻááşááŤá
6.4 Creating Jenkins Pipeline
áĄááŻáááŻáááşááąáŹáˇ áĄáŹá¸ááŻáśá¸ ready ááźá
áşááźáŽááááŻáˇ Jenkins pipeline ááᯠá
ááźáŽá¸ Create ááŻááşáááŻáˇáááŤááźáŽ
Jenkins Dashboard áážáŹáᲠNew Item or Create a job ááᯠáážáááşáááŻááşááŤá
New Item
Pipeline Job name áá
áşááŻááąá¸áááŻááşááŤá ááźáŽá¸áááş Pipeline ááᯠáá˝áąá¸ááźáŽá¸ áááşáá˝áŹá¸áááŻááşááŤá
Sample Pipeline ááąá¸áá˛áˇáᲠCreate ááŻááşááŤáááşá
Pipeline > Select on Pipeline > Click on OK
áĄáá˛ááąáŹááşááźáŽá¸áááŻáááş áááźáŹá¸ Configuration ááᯠáá ááąáˇááŹá¸ááźáŽá¸ áááşáááşááźááşá¸á Pipeline áááŻáá˛áˇááąááŹááᯠáááşá¸áá˝áŹá¸áááŻááşááŤá ááźáŽá¸áááşááąáŹáˇ Definition áážáŹ Pipeline script form SCM
áááŻáá˝áąá¸ááŤáááşá
Go to Pipeline > Pipeline script form SCM
GitHub repo ááᯠJenkins áááą access ááŻááşááąáŹáˇáážáŹ ááááŻáˇ GitHub repo SSH URL ááᯠCopy áá˝áŹá¸áá°áááŻááşááŤá
ááźáŽá¸áááşááąáŹáˇ
SCM áááŻáá˛áˇááąááŹáážáŹ Git áááŻáá˝áąá¸ááŤá
Repository URL ááąááŹáážáŹ copy áá°ááŹáá˛áˇáá˛áˇ GitHub repo SSH URL ááᯠáááˇáşááŤá
Credentials ááąááŹáážáŹáááąáŹáˇ GitHub access áĄáá˝ááş create ááŻááşáá˛áˇáá˛áˇ Credentials ááᯠselect ááŻááşááąá¸áááŻááşáááşáááŤááźáŽá
Git Branch áááŻááąáŹáˇ master áá˛ááŹá¸ááŹá¸ áááŻááşááŤáááşá
áááźáŹá¸ Config áá˝áą ááźááşááťááşááŹáážááááşááźááşáááŻááşá፠ááźáŽá¸áááşááąáŹáˇ Apply and Save
áĄááŻáááŻáááşááąáŹáˇ Pipeline á run áááŻáˇáĄáá˝ááş ready ááŤáá˛á
7. Creating Jenkinsfile and Docker compose
Pipeline á run áááŻáˇáĄáá˝ááş Jenkinsfile áááŻááŤáááşá Application ááᯠDocker Compose áá˛áˇ Run áážáŹááááŻáˇ Dockerfile áá˛áˇ docker-compose.yml áááŻááşáááŻáˇáááşá¸áááŻáĄááşááŤáááşá
7.1 Creating Jenkinsfile
Jenkinsfile áá áşáᯠáĄáááş create ááŻááşááŤáááşá
touch Jenkinsfile
Pipeline Syntax áá˛áˇáááşá¸ Jenkins format áá˝áą generate ááŻááşááááşááŤáááşá
ááŽáážáŹ áĽáááŹáá áşááŻáĄááąáá˛áˇ pipeline ááᯠáááş agent áážáŹ run ááᲠáááŻááŹááᯠlabel áĄááąáá˛áˇ áááşáážááşááźáŽá¸ Jenkinsfile áážáŹáááˇáşááąá¸áááŻáˇáĄáá˝ááş Syntax generate ááŻááşááźááŤáááşá
Jenkinsfile áá˛áážáŹ ááŽáááŻááťááŻá¸ copy ááŻááşááźáŽá¸ááŻáśá¸áááŻááşááŤáááşá
pipeline {
agent {
label 'agent-via-ssh'
}
}
Learn more about Pipeline Syntax > https://www.jenkins.io/doc/book/pipeline/syntax/
áĄááŻááą áĄááŻáááŻáááşááąáŹáˇááťá˝ááşááąáŹáˇáşáážáŹ Jenkinsfile, Dockerfile áá˛áˇ docker-compose.yaml áááŻááźáŽá¸ááŻáśá¸áááŻááşáážáááŤáááşá
ááťá˝ááşááąáŹáş áááąáŹáˇ Pipeline ááᯠJenkins agent áá˛áˇ ááŽá¸áááˇáşááąááŹáážáŹ ááŽá¸áááˇáş workspace áá áşááŻáĄááąáá˛áˇ run ááťááşááŹááááŻáˇ Jenkins agent áá˛áážáŹ directory áá áşáᯠáá˝áŹá¸ááąáŹááşáááŻááşááŤáááşáááŤá optional á፠áááŻááşáááşá¸áááŤáááşá
mkdir -p /home/jenkins/project/react-jenkins-docker/
ááŤáááąáŹáˇ áĄáááŻá¸áážááşá¸ááŻáśá¸ Jenkins áááŻááşá፠workspace location ááᯠenv áĄááąáá˛áˇáááˇáşááŹá¸ááŤáááşá
Jenkinsfile
pipeline {
agent {
label 'agent-via-ssh'
}
environment {
compose_service_name = "react-jenkins-docker"
workspace = "/home/jenkins/project/react-jenkins-docker/"
}
stages {
stage('Checkout Source') {
steps {
ws("${workspace}") {
checkout scm
}
}
}
stage('Docker Comopse Build') {
steps {
ws("${workspace}"){
sh "docker compose build --no-cache ${compose_service_name}"
}
}
}
stage('Docker Comopse Up') {
steps {
ws("${workspace}"){
sh "docker compose up --no-deps -d ${compose_service_name}"
}
}
}
}
}
ááŤáááąáŹáˇ Application run áááŻáˇáĄáá˝ááş Dockerfile áá˛áˇ docker-compose.yaml áááŻááşááŤá
Dockerfile and docker-compose.yaml
# Stage 1:
FROM node:14 as builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Stage 2:
FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html
# COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
version: '3'
services:
react-jenkins-docker:
container_name: react-jenkins-docker
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:80"
Docker áá˛áˇ áááşáááşááŹááťáŹá¸áááŻáááşá¸ ááąáŹááşáááŻááşá¸áážáŹáááşááąá¸áá˝áŹá¸áááŻáˇáážáááŤáááşá
áĄááŻáááŻáááşááąáŹáˇ áĄáá áş create ááŻááşáááŻááşáá˛áˇ ááŻáśá¸áááŻááşááᯠGitHub remote repo ááŽááᯠpush ááŻááşááŤáááşá
git commit -a -m "updated Jenkinsfile, Dockerfile and docker-compose.yaml"
git push origin master
GitHub repo áážáŹ update áá˝áąááąáŹááşááŹááŤááźáŽá
áĄááŻááą pipeline á
áááŻáˇ áĄáá˝ááş Jenkins ááᯠááźááşáá˝áŹá¸ááźáŽá¸ create ááŻááşáá˛áˇáá˛áˇ Pipeline áá˛áááşáááŻááşááŤá
ááźáŽá¸áááşááąáŹáˇáááşáááşááźááşá¸áážáŹáážááá˛áˇ Build now ááᯠáážáááşáááŻááşáááşáááŤááźáŽá
Go to Pipeline > Build Now
pipeline á run áá˝áŹá¸ááŹááᯠáá˝áąáááŤááááˇáşáááşá Console logs áážáŹáááşá¸ ááŹáá˝áą run áá˝áŹá¸áá˛áááŻáᏠáĄááąá¸á áááş logs ááᯠááźááˇáşáááŻááşááŤáááşá
ááźáŽá¸áááşááąáŹáˇ Jenkins agent áá˛áááşááźáŽá¸ react app ááąá¸á Docker container áĄááąáá˛áˇ run ááąááŹá¸áááŻáᏠááźááˇáşááźááˇáşáááŻááşááŤáááşá
docker ps
ááźáŽá¸áááşááąáŹáˇ browser áááąáŹáˇ Jenkins agent áá˛áˇ ip áá˛áˇ port number 8080 ááᯠaccess ááŻááşááźááˇáşáááŻááşááŤá ááááş Real world áážáŹááąáŹáˇ Deployment ááŻááşáááşáˇ server á Jenkins agent áááŻááşáᲠáááşáááş á áŽááźá áşááąáážáŹááŤá
Troubleshooting:
Pipeline run áá˛áˇ áĄá፠Docker permission issue ááźá áşááąáá˛áˇáááşáááŻáááş agent áĄáá˝ááş create ááŻááşááŹá¸áá˛áˇ Jenkins credential áá˛áážáŹ ááŻáśá¸áá˛áˇáá˛áˇ ssh user á Docker usergroup áá˛áážáŹáážáááŹá¸ check ááźááˇáşááŤá áĄáááşá áážáááąáá˛áˇáááˇáşáááŻááş permission issue áá˛ááźá áşááąáááşááąáŹáˇ agent node ááᯠrestart ááťááźáŽá¸ááźááşá ááşá¸ááźááˇáşáááŻááşááŤáááş ec2 ááŻáśá¸áá˛áˇáá°áá˝áąá public ip ááŻáśá¸ááŹá¸áááşáááŻáááş restart ááťáááş ip ááźáąáŹááşá¸áá˝áŹá¸áááŻááşááŤáááşá
Okayy áĄáᯠáááŻáááşááąáŹáˇ Jenkins áá˛áˇ Docker compose ááᯠááŻáśá¸ááźáŽá¸ react application ááᯠdeploy ááŻááşááŹááᯠLab áĄááąáá˛áˇ ááŻááşááźáá˝áŹá¸ááŹááŤááĄáááşááźáąááźáááşáááŻáˇááťážáąáŹáşáááˇáşááŤáááşá step áá˝áąáĄááťáŹá¸ááźáŽá¸ááááŻáˇ áĄáááşáááźáąááŹáážááááş Burmese Bytes áá˛áˇ Communication channel áá áşááŻáᯠáážáŹ ááŹááąá¸áááŻááşááŤáááşá
Thank you for taking the time to read this article! Feel free to connect and share your thoughts or questions. I will also share more on the topic of Jenkins.
Subscribe to my newsletter
Read articles from Wai Yan Soe directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by