Commit bf717dc8 authored by narendra's avatar narendra
Browse files
No related merge requests found
Showing with 132 additions and 0 deletions
+132 -0
# base image
FROM node:14.18.0-alpine
RUN apk --update add git
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY . /app/
RUN npm install -g serve
EXPOSE 5000
# To start app
ENTRYPOINT ["serve", "-s", "build"]
pipeline {
agent{
label 'nodejs'
}
environment {
DOCKER_TAG = "v${env.BUILD_NUMBER}"
}
options{
// Stop the build early in case of compile or test failures
skipStagesAfterUnstable()
}
stages {
stage("Testing"){
steps{
echo "no script"
sh label: '', script: 'chmod +x changeTag.sh'
sh label: '', script: './changeTag.sh ${DOCKER_TAG}'
}
}
stage("Build Project"){
steps{
sh label: '', script: '''npm install --production
npm install react-scripts -g --silent
CI=false npm run build'''
}
}
stage("Building Frontend Image"){
steps{
sh label: '', script: '''docker build -t novisync-web-react-front-prod:v1 .
docker tag novisync-web-react-front-prod:v1 docker-registry-server:5000/novisync-web-react-front-prod:${DOCKER_TAG}'''
}
}
stage("Docker push Frontend Image"){
steps{
sh label: '', script: 'docker push docker-registry-server:5000/novisync-web-react-front-prod:${DOCKER_TAG}'
}
}
stage("Deploy Frontend to k8s"){
steps{
sh label: '', script: 'sshpass -f "/root/suresh/k8s-pro" scp -o StrictHostKeyChecking=no novisync-web-react-frontend.yml root@192.168.6.110:/root/suresh/'
sh label: '', script: 'sshpass -f "/root/suresh/k8s-pro" ssh -o StrictHostKeyChecking=no root@192.168.6.110 \'kubectl apply -f /root/suresh/novisync-web-react-frontend.yml\''
}
}
}
}
def getDockerTag(){
def tag = sh script: ' git rev-parse HEAD', returnStdout: true
return tag
}
#! /bin/bash
tag="$1"
sed -i "s/tagVersion/$tag/g" novisync-web-react-frontend.yml
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: novisync-web-react-front-prod
namespace: nodejsprod
spec:
replicas: 1
selector:
matchLabels:
app: novisync-web-react-front-prod-app
template:
metadata:
labels:
app: novisync-web-react-front-prod-app
spec:
containers:
- image: docker-registry-server:5000/novisync-web-react-front-prod:tagVersion
name: novisync-web-react-front-prod-cont
resources:
requests:
memory: "1Mi"
cpu: "0.1"
limits:
memory: "1000Mi"
cpu: "0.7"
---
apiVersion: v1
kind: Service
metadata:
name: novisync-web-react-front-prod-svc
namespace: nodejsprod
spec:
selector:
app: novisync-web-react-front-prod-app
type: NodePort
ports:
- nodePort: 31194
port: 5000
targetPort: 5000
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: novisync-web-react-front-prod-autoscale
namespace: nodejsprod
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: novisync-web-react-front-prod
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 75
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment