Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .env
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_KEY=
CLOUDINARY_SECRET=
MAPBOX_TOKEN=
DB_URL=" "
CLOUDINARY_CLOUD_NAME=dmwaef1yg
CLOUDINARY_KEY=174288424886845
CLOUDINARY_SECRET=IRnxIvuIwVWAnS3daNUFVRT8N7c
MAPBOX_TOKEN=sk.eyJ1IjoicmFuaml0cjAwMSIsImEiOiJjbHg0aXRlcncxM2xkMmtzNDkwcm8zbWZpIn0._-Z0itv0q7xhScy6BsZKzg
DB_URL="mongodb+srv://rrvox001:[email protected]/?retryWrites=true&w=majority&appName=ranjit"
SECRET=devopsshack
27 changes: 15 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Use Node 18 as parent image
FROM node:18
# Use an official Node.js runtime as the base image
FROM node:14

# Change the working directory on the Docker image to /app
WORKDIR /app
# Set the working directory in the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the /app directory
COPY package.json package-lock.json ./
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm install
# Install project dependencies
RUN npm install --quiet

# Copy the rest of project files into this image
# Upgrade multer to the specified version
RUN npm install [email protected] --quiet

# Copy the rest of the application code
COPY . .

# Expose application port
# Expose the port the app runs on
EXPOSE 3000

# Start the application
CMD npm start
# Start the Node.js application
CMD ["node", "app.js"]
77 changes: 77 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
pipeline {
agent any

tools {
nodejs 'node21'
}

environment {
SCANNER_HOME = tool 'sonar-scanner'
}

stages {
stage('Git Checkout') {
steps {
git branch: 'main', url: 'https://github.com/ranjitrupnawar/3-Tier-Full-Stack.git'
}
}

stage('Install dependency package') {
steps {
sh 'npm install'
}
}

stage('Trivy FS Scan') {
steps {
sh 'trivy fs --format table -o fs-report.html .'
}
}

stage('SonarQube Analysis') {
steps {
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
sh "$SCANNER_HOME/bin/sonar-scanner -Dsonar.projectKey=campground -Dsonar.projectName=campground -Dsonar.login=$SONAR_TOKEN"
}
}
}

stage('Docker build and tag') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-cred', toolName: 'docker') {
sh "docker build -t ranjitrupnawar/camp:latest ."
}
}
}
}

stage('Trivy Image scan') {
steps {
sh 'trivy image --format table -o image-report.html ranjitrupnawar/camp:latest'
}
}

stage('Docker push') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-cred', toolName: 'docker') {
sh "docker push ranjitrupnawar/camp:latest"
}
}
}
}

stage('Docker deployment') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-cred', toolName: 'docker') {
sh "docker run -d -p 3000:3000 ranjitrupnawar/camp:latest"
}
}
}
}
}


}
10 changes: 5 additions & 5 deletions Manifests/dss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ metadata:
name: yelp-camp-secrets
type: Opaque
data:
CLOUDINARY_CLOUD_NAME: ZGlpMnJvenRw
CLOUDINARY_KEY: NzU3NjQzMjU3ODkxMzY0
CLOUDINARY_SECRET: SHpBeTdPU3VCZjJhSUFSUm5Fd0tIcEVtc01N
CLOUDINARY_CLOUD_NAME: ZG13YWVmMXlnCg==
CLOUDINARY_KEY: MTc0Mjg4NDI0ODg2ODQ1Cg==
CLOUDINARY_SECRET: SVJueEl2dUl3VldBblMzZGFOVUZWUlQ4TjdjCg==
MAPBOX_TOKEN: cGsuZXlKMUlqb2lZV1JwYW1GcGMzZGhiQ0lzSW1FaU9pSmpiSFl3TnpKemVHNHhaRzR5TW1wd1ltWm1OSFZ3YlhObUluMC5SVlFZc3UwUnZKZ0NGNTRrMjJkWDBB
DB_URL: bW9uZ29kYitzcnY6Ly9qYWlzd2FsYWRpMjQ2OnNjN1ZHU3lkN2RRQ2NMeTFAY2x1c3RlcjAuaXE2bXV0aC5tb25nb2RiLm5ldC8/cmV0cnlXcml0ZXM9dHJ1ZSZ3PW1ham9yaXR5JmFwcE5hbWU9Q2x1c3RlcjA=
DB_URL: bW9uZ29kYitzcnY6Ly9ycnZveDAwMTpFdkVKcm12bGlWWm1NZmtDQHJhbmppdC55ZWFnbGh0Lm1vbmdvZGIubmV0Lz9yZXRyeVdyaXRlcz10cnVlJnc9bWFqb3JpdHkmYXBwTmFtZT1yYW5qaXQK
SECRET: ZGV2b3Bzc2hhY2s=

---
Expand All @@ -29,7 +29,7 @@ spec:
spec:
containers:
- name: yelp-camp-container
image: adijaiswal/campa:latest
image: ranjitrupnawar/camp:latest
ports:
- containerPort: 3000
env:
Expand Down