diff --git a/.github/workflows/service-deploy.yaml b/.github/workflows/service-deploy.yaml
new file mode 100644
index 0000000..36cd24c
--- /dev/null
+++ b/.github/workflows/service-deploy.yaml
@@ -0,0 +1,43 @@
+name: Netflix Movie Catalog Service Deployment
+
+on:
+ push:
+ branches:
+ - main
+
+env:
+ EC2_PUBLIC_IP: "51.20.87.72" # TODO replace to your EC2 instance public IP
+ SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} # TODO define this secret in your GitHub repo settings
+
+jobs:
+ Deploy:
+ name: Deploy in EC2
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout the app code
+ uses: actions/checkout@v2
+
+ - name: Build and push image
+ run: |
+ echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
+ IMAGE_NAME=royeb/netflix-frontend:${{ github.run_number }}
+ docker build -t $IMAGE_NAME .
+ docker push $IMAGE_NAME
+ - name: SSH to EC2 instance
+ run: |
+ echo "$SSH_PRIVATE_KEY" > roye-key.pem
+ chmod 400 roye-key.pem
+
+ # Copy the files from the current wrok dir into the EC2 instance, under `~/app`.
+ scp -o StrictHostKeyChecking=no -i roye-key.pem deploy.sh ubuntu@$EC2_PUBLIC_IP:~/app
+
+ # Connect to your EC2 instance and execute the `deploy.sh` script (this script is part of the repo files).
+ # You need to implement the `deploy.sh` script yourself.
+ #
+ # Upon completion, the NetflixMovieCatalog app should be running with its newer version.
+ # To keep the app running in the background independently on the terminal session you are logging to, configure it as a Linux service.
+
+ ssh -i roye-key.pem ubuntu@$EC2_PUBLIC_IP "bash /home/ubuntu/app/deploy.sh"
+ #
+
+
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
Made by{' '} - Ayushi Gupta + Ayushi Gupta and Roye!!!!!
diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..a25676f --- /dev/null +++ b/deploy.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker-compose -f /home/ubuntu/app/docker-compose.yaml down --rmi all +docker compose -f /home/ubuntu/app/docker-compose.yaml up -d \ No newline at end of file diff --git a/pipelines/build-dev.Jenkinsfile b/pipelines/build-dev.Jenkinsfile new file mode 100644 index 0000000..951bed6 --- /dev/null +++ b/pipelines/build-dev.Jenkinsfile @@ -0,0 +1,56 @@ +pipeline { + agent { + label 'general' + } + + triggers { + githubPush() // trigger the pipeline upon push event in github + } + + options { + timeout(time: 10, unit: 'MINUTES') // discard the build after 10 minutes of running + timestamps() // display timestamp in console output + } + + environment { + // GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + // TIMESTAMP = new Date().format("yyyyMMdd-HHmmss") + + IMAGE_TAG = "v1.0.$BUILD_NUMBER" + IMAGE_BASE_NAME = "netflix-frontend-dev" + + DOCKER_CREDS = credentials('dockerhub') + DOCKER_USERNAME = "${DOCKER_CREDS_USR}" // The _USR suffix added to access the username value + DOCKER_PASS = "${DOCKER_CREDS_PSW}" // The _PSW suffix added to access the password value + } + + stages { + stage('Docker setup') { + steps { + sh ''' + docker login -u $DOCKER_USERNAME -p $DOCKER_PASS + ''' + } + } + + stage('Build & Push') { + steps { + sh ''' + IMAGE_FULL_NAME=$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG + + docker build --push -t $IMAGE_FULL_NAME . + ''' + } + } + + + stage('Trigger Deploy') { + steps { + build job: 'front-deploy-dev', wait: false, parameters: [ + string(name: 'SERVICE_NAME', value: "NetflixFrontend"), + string(name: 'IMAGE_FULL_NAME_PARAM', value: "$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG") + ] + } + } + } +} \ No newline at end of file diff --git a/pipelines/build.jenkinsfile b/pipelines/build.jenkinsfile new file mode 100644 index 0000000..7a169a6 --- /dev/null +++ b/pipelines/build.jenkinsfile @@ -0,0 +1,46 @@ +pipeline { + agent { + label 'general' + } + + triggers { + githubPush() // trigger the pipeline upon push event in github + } + + options { + timeout(time: 10, unit: 'MINUTES') // discard the build after 10 minutes of running + timestamps() // display timestamp in console output + } + + environment { + // GIT_COMMIT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + // TIMESTAMP = new Date().format("yyyyMMdd-HHmmss") + + IMAGE_TAG = "v1.0.$BUILD_NUMBER" + IMAGE_BASE_NAME = "netflix-frontend" + + DOCKER_CREDS = credentials('dockerhub') + DOCKER_USERNAME = "${DOCKER_CREDS_USR}" // The _USR suffix added to access the username value + DOCKER_PASS = "${DOCKER_CREDS_PSW}" // The _PSW suffix added to access the password value + } + + stages { + stage('Docker setup') { + steps { + sh ''' + docker login -u $DOCKER_USERNAME -p $DOCKER_PASS + ''' + } + } + + stage('Build & Push') { + steps { + sh ''' + IMAGE_FULL_NAME=$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG + + docker build --push -t $IMAGE_FULL_NAME . + ''' + } + } + } +} \ No newline at end of file diff --git a/pipelines/test.jenkinsfile b/pipelines/test.jenkinsfile new file mode 100644 index 0000000..695d82a --- /dev/null +++ b/pipelines/test.jenkinsfile @@ -0,0 +1,44 @@ +pipeline { + agent any + + stages { + stage('Tests before build') { + parallel { + stage('Unittest') { + steps { + sh 'echo unittesting...' + } + } + stage('Lint') { + steps { + sh 'echo linting...' + } + } + } + } + stage('Build and deploy to Test environment') { + steps { + sh 'echo trigger build and deploy pipelines for test environment... wait until successful deployment' + } + } + stage('Tests after build') { + parallel { + stage('Security vulnerabilities scanning') { + steps { + sh 'echo scanning for vulnerabilities...' + } + } + stage('API test') { + steps { + sh 'echo testing API...' + } + } + stage('Load test') { + steps { + sh 'echo testing under load...' + } + } + } + } + } +}