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
43 changes: 43 additions & 0 deletions .github/workflows/service-deploy.yaml
Original file line number Diff line number Diff line change
@@ -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"
#


3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:14.0.0-alpine3.11
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
CMD ["npm", "start"]
3 changes: 3 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions pipelines/build.jenkinsfile
Original file line number Diff line number Diff line change
@@ -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"

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', wait: false, parameters: [
string(name: 'SERVICE_NAME', value: "NetflixFrontend"),
string(name: 'IMAGE_FULL_NAME_PARAM', value: "$DOCKER_USERNAME/$IMAGE_BASE_NAME:$IMAGE_TAG")
]
}
}
}
}
44 changes: 44 additions & 0 deletions pipelines/test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -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...'
}
}
}
}
}
}