diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml deleted file mode 100644 index 08d3026f..00000000 --- a/.github/workflows/firebase-hosting-merge.yml +++ /dev/null @@ -1,23 +0,0 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools - -name: Deploy to Firebase Hosting on merge -'on': - push: - branches: - - main -jobs: - build_and_deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: npm ci && npm run build - env: - VITE_APP_API_ENDPOINT_URL: '${{ secrets.VITE_APP_API_ENDPOINT_URL }}' - VITE_APP_TMDB_V3_API_KEY: '${{ secrets.VITE_APP_TMDB_V3_API_KEY }}' - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WEBSITES_F0426 }}' - channelId: live - projectId: websites-f0426 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml deleted file mode 100644 index a56481bc..00000000 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ /dev/null @@ -1,17 +0,0 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools - -name: Deploy to Firebase Hosting on PR -'on': pull_request -jobs: - build_and_preview: - if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: npm ci && npm run build - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WEBSITES_F0426 }}' - projectId: websites-f0426 diff --git a/.gitignore b/.gitignore index f1887470..14b10131 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,5 @@ .env.production.local npm-debug.log* -yarn.lock yarn-debug.log* yarn-error.log* diff --git a/Dockerfile b/Dockerfile index e8455afe..5e81b022 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16.17.0-alpine as builder +FROM node:16.17.0-alpine AS builder WORKDIR /app COPY ./package.json . COPY ./yarn.lock . diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..8d3187af --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,133 @@ +pipeline { + agent any + + tools { + nodejs 'NodeJS' + } + + environment { + SONARQUBE_SCANNER = tool 'Sonar' + DOCKER_CREDENTIALS = credentials('Docker') + TMDB_CREDENTIALS = credentials('tmdb') + } + + stages { + stage('Clean Workspace') { + steps { + echo "Cleaning Workspace..." + cleanWs() + echo 'Workspace cleaned.' + } + } + + stage('Clone GitHub Repository') { + steps { + script { + echo 'Cloning GitHub repository...' + git branch: 'main', url: 'https://github.com/Abdullah-0-3/NetflixCloneK8s.git' + } + echo 'Cloning done.' + } + } + + stage('SonarQube Quality Analysis') { + steps { + script { + withSonarQubeEnv('Sonar') { + echo 'SonarQube scanner environment configured.' + sh "${SONARQUBE_SCANNER}/bin/sonar-scanner -Dsonar.projectName=NetflixClone -Dsonar.projectKey=NetflixClone" + } + } + echo 'SonarQube analysis started.' + } + } + + stage('Install Dependencies') { + steps { + script { + sh 'npm install' + echo 'Dependencies installed.' + } + } + } + + stage('OWASP Dependency Check') { + steps { + script { + dependencyCheck additionalArguments: '--scan', odcInstallation: 'dc' + dependencyCheckPublisher pattern: '**/dependency-check-report.xml' + echo 'OWASP Dependency Check completed.' + } + } + } + + stage('SonarQube Gate Analysis') { + steps { + script { + echo 'Waiting for SonarQube gate analysis...' + timeout(time: 2, unit: 'MINUTES'){ + waitForQualityGate abortPipeline: false + } + + } + } + } + + stage('Trivy File System Scan') { + steps { + script { + sh 'trivy fs --quiet --ignore-unfixed --format json . > trivy-fs-scan.txt' + echo 'Trivy file system scan completed.' + } + } + } + + stage('Build Docker Image') { + steps { + script { + def imageName = "muhammadabdullahabrar/devops:netflix-clone" + sh "docker build --build-arg TMDB_V3_API_KEY=${TMDB_CREDENTIALS} -t ${imageName} ." + echo 'Docker image built.' + } + } + } + + stage('Trivy Image Scan') { + steps { + script { + def imageName = "muhammadabdullahabrar/devops:netflix-clone" + sh "trivy image --quiet --ignore-unfixed --format json ${imageName} > trivy-image-scan.txt" + echo 'Trivy image scan completed.' + } + } + } + + stage('Push Image to Docker Hub') { + steps { + withCredentials([usernamePassword(credentialsId: 'Docker', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) { + script { + def imageName = "muhammadabdullahabrar/devops:netflix-clone" + sh """ + set -x + echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin + docker push ${imageName} + docker logout + """ + } + } + } + } + + stage('Send Email with Attachments') { + steps { + emailext( + attachLog: true, + subject: "Netflix Clone Pipeline - Jenkins", + body: """Project: ${env.JOB_NAME} - ${env.BUILD_NUMBER} has been built successfully. Check console output at ${env.BUILD_URL}.""", + to: 'abdullahabrar4843@gmail.com', // Change mail here + attachmentsPattern: 'trivy-fs-scan.txt,trivy-image-scan.txt,dependency-check-report.xml' + ) + } + } + } +} \ No newline at end of file diff --git a/Netflix Clone Deployment - DevSecOps Project.pdf b/Netflix Clone Deployment - DevSecOps Project.pdf new file mode 100644 index 00000000..1d9958b4 Binary files /dev/null and b/Netflix Clone Deployment - DevSecOps Project.pdf differ diff --git a/README.md b/README.md index 25693bed..efde81f8 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,305 @@ -
- -Home Page
-Mini Portal
-Detail Modal
-Grid Genre Page
-Watch Page with customer contol bar
-