Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s #9

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use a slim Node.js base image for building
FROM node:18-slim AS builder

# Set working directory
WORKDIR /app

# Copy package.json and other package management files
COPY package*.json ./

# Install dependencies (use RUN for development, COPY for production)
RUN npm install # For development builds

# Optional: Copy your application code in a separate stage
FROM node:18-slim

# Set working directory
WORKDIR /app

# Copy your application code
COPY . .

# Expose the port your application uses (replace 8080 with your actual port)
EXPOSE 3000

# Start the application (replace "start.js" with your entry point)
CMD [ "npm", "start" ] # Or "node start.js"

5 changes: 5 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
redis:
image: 'dpka531/deepika:latest'
ports:
- '4000:4000'
71 changes: 71 additions & 0 deletions jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
pipeline {
agent any

tools{
nodejs 'node18'
}

environment {
SCANNER_HOME=tool 'sonarqube'
}

stages {
stage('clean workspace'){
steps{
cleanWs()
}
}

stage('Checkout') {
steps {
// Check out the code from Git repository
git credentialsId: 'github', url: 'https://github.com/deepikapwr/node-express-server-rest-api.git'
}
}


stage("Sonarqube Analysis "){
steps{
withSonarQubeEnv('sonarqube') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=job \
-Dsonar.projectKey=job '''
}
}
}
stage("quality gate"){
when { expression { params.action == 'create'}}
steps{
script{
def credentialsId = 'sonarqube'
qualityGate(credentialsId)
}
}
}

stage('Install Dependencies') {
steps {
// Build your application artifact
sh 'npm install'
}
}

stage("Docker Build & Push"){
steps{
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh "docker build -t deepika ."
sh "docker tag deepika dpka531/deepika:latest "
sh "docker push dpka531/deepika:latest "
}
}
}
}

stage('Deploy (Optional)') {
steps {
sh 'docker-compose up -d'
}
}

}
}