Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
69ed146
Update Google OAuth credentials in .env.sample
harisamjad0158 Oct 15, 2025
2df409b
Add .env.local file
harisamjad0158 Oct 15, 2025
8bf4609
Update .env.local
harisamjad0158 Oct 15, 2025
4dc4267
Update .env.local
harisamjad0158 Oct 15, 2025
59a5870
Update secrets in kind/secrets.yml with real values
harisamjad0158 Oct 15, 2025
fd392ab
Update Google OAuth and NextAuth credentials
harisamjad0158 Oct 15, 2025
178443f
Update .env.local with new credentials and URIs
harisamjad0158 Oct 15, 2025
56ca962
Update secrets.yml
harisamjad0158 Oct 15, 2025
2f30780
Update secrets.yml
harisamjad0158 Oct 16, 2025
baae071
Change NEXTAUTH_URL to new server address
harisamjad0158 Oct 16, 2025
c690658
Update NEXTAUTH_URL in configmap.yml
harisamjad0158 Oct 16, 2025
8a273b6
Add GOOGLE_ID to gemini-config ConfigMap
harisamjad0158 Oct 16, 2025
a396266
Add MONGODB_URI to gemini-config ConfigMap
harisamjad0158 Oct 16, 2025
b62e8d7
Add MONGODB_INITDB_ROOT_USERNAME to configmap
harisamjad0158 Oct 16, 2025
308bcd6
Update secrets with new base64 encoded values1
harisamjad0158 Oct 16, 2025
7f842b1
Update secrets.yml
harisamjad0158 Oct 16, 2025
7e7d1ef
Update GOOGLE_ID in configmap.yml
harisamjad0158 Oct 16, 2025
cd9b399
Change GOOGLE_ID in kind/secrets.yml
harisamjad0158 Oct 16, 2025
88d801f
Update GOOGLE_ID in configmap.yml
harisamjad0158 Oct 16, 2025
7d20863
Update .env.local
harisamjad0158 Oct 16, 2025
0a7f476
Update OAuth and NextAuth secrets in .env.local
harisamjad0158 Oct 16, 2025
b4dd3c5
Update configmap.yml
harisamjad0158 Oct 16, 2025
bd284a3
Change MONGODB_URI to new base64 encoded value
harisamjad0158 Oct 16, 2025
15fbc94
Update secrets.yml
harisamjad0158 Oct 16, 2025
660357d
Add Jenkins pipeline for CI/CD process
harisamjad0158 Oct 16, 2025
e0515c2
Update Jenkins configuration with new plugins
harisamjad0158 Oct 16, 2025
71264aa
Update service type to NodePort and set nodePort
harisamjad0158 Oct 21, 2025
0ddb282
Update Git repository URL in Jenkinsfile
harisamjad0158 Oct 23, 2025
3d6c711
Update Jenkinsfile
harisamjad0158 Oct 29, 2025
9f40e45
Update Jenkinsfile
harisamjad0158 Oct 29, 2025
20b1e4f
Update Dockerfile
harisamjad0158 Oct 29, 2025
b005c7f
Update secrets.yml
harisamjad0158 Oct 29, 2025
b959f8c
Update Jenkinsfile
harisamjad0158 Oct 29, 2025
6ff3caf
Update Git repository URL in Jenkinsfile
harisamjad0158 Oct 29, 2025
0eb3d95
Update Jenkinsfile for agent and scanning improvements
harisamjad0158 Oct 30, 2025
903e83b
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
c0eb3b0
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
8f507fc
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
18e139a
Add 'Wait for Containers' stage in Jenkinsfile
harisamjad0158 Oct 30, 2025
991941d
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
2526552
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
0113b68
Update Git repository URL in Jenkinsfile
harisamjad0158 Oct 30, 2025
a022558
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
fc63f66
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
d15aae3
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
6989973
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
4dc9284
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
937f162
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
821a2ca
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
1b289a8
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
f5aceb3
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
c8a5e8e
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
1eafeeb
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
c3f88f8
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
bd5cc23
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
b39928e
Update Jenkinsfile
harisamjad0158 Oct 30, 2025
9d4bad3
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
df4dea4
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
b02b956
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
1e837c8
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
49107e0
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
c0e3cc4
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
3f29978
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
e18ade4
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
d9298f8
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
d8becf9
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
60cc712
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
f5f363c
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
fb937b2
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
66a2206
Update Jenkinsfile
harisamjad0158 Oct 31, 2025
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
15 changes: 15 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Google OAuth credentials
GOOGLE_ID=843731093025-eol05fgfiajku69sg3b9opvuautbe07v.apps.googleusercontent.com
GOOGLE_SECRET=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

# MongoDB connection string - CONTAINS PASSWORD
MONGODB_URI=mongodb+srv://alipeco90_db_user:D7Xr4ExRbiavbE6K@cluster0.bnl24cv.mongodb.net/

# NextAuth secret - Use PLAIN TEXT DECODED value here
NEXTAUTH_SECRET=qt9cV37G2WGd1fZtGjNWnh42XSC087HyMGlB349dhfY=

# Base URL for the application
NEXTAUTH_URL=https://72.61.159.174.nip.io

# Google API Key - Use PLAIN TEXT DECODED value here
NEXT_PUBLIC_API_KEY=AIzaSyB1e0MSZ4SC_m43jUisDft2p7lPcqem3v8
15 changes: 0 additions & 15 deletions .env.sample

This file was deleted.

49 changes: 9 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,19 @@
##################################
# Stage 1: Build Stage
##################################
FROM node:18-alpine AS builder
# This is now a single-stage build

# Add metadata for authorship and app identification
LABEL maintainer="Amitabh Soni <amitabhdevops2024@gmail.com>" \
app="gemini" \
stage="build"
FROM node:18-alpine
LABEL maintainer="Amitabh Soni <amitabhdevops2024@gmail.com>" app="gemini" stage="build"

WORKDIR /app

# Install build dependencies
# Copy package files and install dependencies
COPY package.json package-lock.json* ./
RUN npm ci

# Copy source and build
# Copy the rest of the application code
COPY . .
RUN npm run build

# Clean up dev dependencies after build
RUN rm -rf node_modules && npm cache clean --force

##################################
# Stage 2: Production Stage
##################################
FROM node:18-alpine AS production

# Add metadata for the final image
LABEL maintainer="Amitabh Soni <amitabhdevops2024@gmail.com>" \
app="gemini" \
stage="production"

WORKDIR /app

# Install only production dependencies
COPY package.json package-lock.json* ./
RUN npm ci --production && npm cache clean --force

# Copy minimal required files
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.mjs ./

# Set production environment
ENV NODE_ENV=production

EXPOSE 3000
# Build the application
RUN npm run build

CMD ["npm", "start"]
# Set the command to start the app
CMD ["npm", "start"]
215 changes: 38 additions & 177 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,187 +1,48 @@
@Library('Shared')_

pipeline {
agent { label 'dev-server' }
agent { label 'devsecops-agent' }

environment {
SONAR_HOME = tool "Sonar"
DOCKER_IMAGE = "gemininip"
GIT_REPO = "https://github.com/Amitabh-DevOps/dev-gemini-clone.git"
GIT_BRANCH = "kind"
DOCKERHUB_USERNAME = "amitabhdevops"
DOCKER_IMAGE_NAME = "${DOCKERHUB_USERNAME}/${DOCKER_IMAGE}"
}
parameters {
string(name: 'GEMINI_DOCKER_TAG', defaultValue: 'v1', description: 'Setting docker image for latest push')
}
stages {
stage("Clean Workspace") {
steps {
cleanWs()
}
}
stage("Code") {
steps {
// Use GIT_REPO and GIT_BRANCH from environment variables
clone("${GIT_REPO}", "${GIT_BRANCH}")
echo "Code cloning done from ${GIT_REPO} branch ${GIT_BRANCH}."
}
}
stage("Prepare Environment File") {
steps {
prepareEnvFile('.env.local', '.env.local')
}
environment {
SONAR_HOST_URL = "http://sonarqube-sonarqube.sonarqube.svc.cluster.local:9000"
SONAR_PROJECT_KEY = "dev-gemini"
}
stage("Build") {
steps {
dockerbuild("${DOCKER_IMAGE}", "${params.GEMINI_DOCKER_TAG}")
echo "Docker image ${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG} built successfully."
}
}
stage("SonarQube Quality Analysis") {
steps {
sonarqube_analysis('Sonar', "${DOCKER_IMAGE}", "${DOCKER_IMAGE}")
}
}
stage("OWASP : Dependency Check") {
steps {
owasp_dependency()
}
}
stage("Sonar Quality Gate Scan") {
steps {
sonarqube_code_quality()

stages {
stage('Clone Code') {
steps {
echo "--- Cloning source code ---"
git branch: 'feat/kind', url: 'https://github.com/harisamjad0158/dev-gemini-clone.git'
}
}
}
stage("Docker Image Security Scan (Trivy)") {
steps {
dockerScanTrivy("${DOCKER_IMAGE}", "${params.GEMINI_DOCKER_TAG}")
echo "Trivy scan completed for ${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG}."

stage('Test SonarQube Connection') {
steps {
container('sonar') {
withCredentials([string(credentialsId: 'sonarqube-token', variable: 'SONAR_TOKEN')]) {
sh '''
echo "--- Testing SonarQube Connection ---"
response=$(curl -s -o /dev/null -w "%{http_code}" \
-u ${SONAR_TOKEN}: \
${SONAR_HOST_URL}/api/server/version)

if [ "$response" = "200" ]; then
echo "✅ SonarQube connection successful!"
else
echo "❌ SonarQube connection failed with HTTP code $response"
exit 1
fi
'''
}
}
}
}
}
stage("Push to DockerHub") {
steps {
dockerpush("dockerHub", "${DOCKER_IMAGE}", "${params.GEMINI_DOCKER_TAG}")
echo "Pushed ${DOCKERHUB_USERNAME}/${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG} to DockerHub."

post {
success {
echo "✅ Jenkins and SonarQube are successfully synced!"
}
}
// Uncommented and updated the "Run Container" stage to use environment variables
// stage("Run Container") {
// steps {
// dockerRunApp("${DOCKER_IMAGE}", "${params.GEMINI_DOCKER_TAG}", "env_local", "${DOCKER_IMAGE}", "--env-file .env.local -p 3000:3000")
// echo "Container started using ${DOCKER_IMAGE}:${DOCKER_TAG} with container name '${DOCKER_IMAGE}'."
// }
// }
stage("Cleanup Docker Images") {
steps {
script {
sh "docker rmi ${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG} || true"
sh "docker rmi ${DOCKERHUB_USERNAME}/${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG} || true"
sh "docker image prune -f"
}
echo "Cleaned up Docker image: ${DOCKERHUB_USERNAME}/${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG}."
failure {
echo "❌ Jenkins could not connect to SonarQube. Check token or URL."
}
}
}
post {
success {
archiveArtifacts artifacts: 'kind/gemini-deployment.yml', followSymlinks: false
build job: "Gemini-CD", parameters: [
string(name: 'GEMINI_DOCKER_TAG', value: "${params.GEMINI_DOCKER_TAG}"),
string(name: 'DOCKER_IMAGE_NAME', value: "${DOCKER_IMAGE_NAME}"),
]
echo "Pipeline completed successfully!"
emailext (
subject: "SUCCESS: Jenkins Pipeline for ${DOCKER_IMAGE}",
body: """
<div style="font-family: Arial, sans-serif; padding: 20px; border: 2px solid #4CAF50; border-radius: 10px;">
<h2 style="color: #4CAF50;">🎉 Pipeline Execution: SUCCESS 🎉</h2>
<p style="font-size: 16px; color: #333;">
Hello Team,
</p>
<p style="font-size: 16px; color: #333;">
The Jenkins CI pipeline for <strong style="color: #4CAF50;">${DOCKER_IMAGE}</strong> completed <strong style="color: #4CAF50;">successfully</strong>!
</p>
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
<tr style="background-color: #f2f2f2;">
<th style="text-align: left; padding: 8px; border: 1px solid #ddd;">Details</th>
<th style="text-align: left; padding: 8px; border: 1px solid #ddd;">Values</th>
</tr>
<tr>
<td style="padding: 8px; border: 1px solid #ddd;">Git Repository</td>
<td style="padding: 8px; border: 1px solid #ddd;">${GIT_REPO}</td>
</tr>
<tr>
<td style="padding: 8px; border: 1px solid #ddd;">Branch</td>
<td style="padding: 8px; border: 1px solid #ddd;">${GIT_BRANCH}</td>
</tr>
<tr>
<td style="padding: 8px; border: 1px solid #ddd;">Docker Image</td>
<td style="padding: 8px; border: 1px solid #ddd;">${DOCKERHUB_USERNAME}/${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG}</td>
</tr>
</table>
<p style="font-size: 16px; color: #333; margin-top: 20px;">
Visit <a href="${BUILD_URL}" style="color: #4CAF50;">Pipeline Logs</a> for more details.
</p>
<p style="font-size: 16px; color: #333; margin-top: 20px;">
Thanks,<br>
<strong>Jenkins</strong>
</p>
</div>
""",
to: "amitabhdevops2024@gmail.com",
from: "jenkins@example.com",
mimeType: 'text/html',
attachmentsPattern: '**/table-report.html'
)
}
failure {
echo "Pipeline failed. Please check the logs."
emailext (
subject: "FAILURE: Jenkins Pipeline for ${DOCKER_IMAGE}",
body: """
<div style="font-family: Arial, sans-serif; padding: 20px; border: 2px solid #F44336; border-radius: 10px;">
<h2 style="color: #F44336;">🚨 Pipeline Execution: FAILURE 🚨</h2>
<p style="font-size: 16px; color: #333;">
Hello Team,
</p>
<p style="font-size: 16px; color: #333;">
Unfortunately, the Jenkins CI pipeline for <strong style="color: #F44336;">${DOCKER_IMAGE}</strong> has <strong style="color: #F44336;">failed</strong>.
</p>
<table style="width: 100%; border-collapse: collapse; margin-top: 20px;">
<tr style="background-color: #f2f2f2;">
<th style="text-align: left; padding: 8px; border: 1px solid #ddd;">Details</th>
<th style="text-align: left; padding: 8px; border: 1px solid #ddd;">Values</th>
</tr>
<tr>
<td style="padding: 8px; border: 1px solid #ddd;">Git Repository</td>
<td style="padding: 8px; border: 1px solid #ddd;">${GIT_REPO}</td>
</tr>
<tr>
<td style="padding: 8px; border: 1px solid #ddd;">Branch</td>
<td style="padding: 8px; border: 1px solid #ddd;">${GIT_BRANCH}</td>
</tr>
<tr>
<td style="padding: 8px; border: 1px solid #ddd;">Docker Image</td>
<td style="padding: 8px; border: 1px solid #ddd;">${DOCKERHUB_USERNAME}/${DOCKER_IMAGE}:${params.GEMINI_DOCKER_TAG}</td>
</tr>
</table>
<p style="font-size: 16px; color: #333; margin-top: 20px;">
Visit <a href="${BUILD_URL}" style="color: #F44336;">Pipeline Logs</a> for more details.
</p>
<p style="font-size: 16px; color: #333; margin-top: 20px;">
Thanks,<br>
<strong>Jenkins</strong>
</p>
</div>
""",
to: "amitabhdevops2024@gmail.com",
from: "jenkins@example.com",
mimeType: 'text/html',
attachmentsPattern: '**/table-report.html'
)
}
}
}


37 changes: 37 additions & 0 deletions kind/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pipeline {
agent {
label 'jenkins-jenkins-agent'
}

environment {
MY_ENV = "production"
}

stages {
stage('Clone Code') {
steps {
git url: 'https://github.com/harisamjad0158/dev-gemini-clone.git', branch: 'feat/kind'
}
}

stage('Build') {
steps {
echo "Building application..."
sh 'echo Build done!'
}
}

stage('Test') {
steps {
echo "Running tests..."
sh 'echo Tests passed!'
}
}

stage('Deploy') {
steps {
echo "Deploying to ${MY_ENV} environment"
}
}
}
}
14 changes: 13 additions & 1 deletion kind/configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ metadata:
name: gemini-config
namespace: gemini-namespace
data:
NEXTAUTH_URL: <enter-your-domain-url> # Enter your NextAuth URL here(Domain name/URL)
# Google OAuth Client ID (Public)
GOOGLE_ID: 843731093025-0iooes2k63ir68cn0bvvqlb2h220f9qc.apps.googleusercontent.com

# WARNING: This should be in a SECRET! Only non-sensitive variables should be here.
# The username is EMBEDDED in this URI: alipeco90_db_user
MONGODB_URI: mongodb+srv://alipeco90_db_user:D7Xr4ExRbiavbE6K@cluster0.bnl24cv.mongodb.net/

# Application Base URL
NEXTAUTH_URL: https://72.61.159.174.nip.io

# Explicitly define the application's database username, if needed by the code
# The previous name 'MONGODB_INITDB_ROOT_USERNAME' is typically used for initializing a local DB, not connecting to Atlas.
MONGODB_USERNAME: alipeco90_db_user
Loading