Git Product home page Git Product logo

phpapp's Introduction

docker run -p 8080:80 -e RDS_HOSTNAME=your-rds-endpoint -e RDS_DB_NAME=your-database-name -e RDS_USERNAME=your-database-user -e RDS_PASSWORD=your-database-password php-docker-rds




pipeline {
    agent any
    environment {
        AWS_ACCOUNT_ID = "159012065560"
        AWS_DEFAULT_REGION = "us-east-1"
        IMAGE_REPO_NAME = "phpapplication"
        IMAGE_TAG = "latest"
        AWS_CREDENTIALS_ID = "aws_id"
        JENKINS_CREDENTIALS_ID = "ssh_cred"
        REPOSITORY_URI = "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_REPO_NAME}"
        EC2_INSTANCE_IP = '54.152.22.213'  // Replace with your EC2 instance's IP or DNS
        
    }

    stages {
        stage('Logging into AWS ECR') {
            steps {
                script {
                    sh "aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com"
                }
            }
        }

        stage('Cloning Git') {
            steps {
                git branch: 'main', url: 'https://github.com/santoshbd67/phpapp.git'
            }
        }

        stage('Building image') {
            steps {
                script {
                    dockerImage = docker.build "${IMAGE_REPO_NAME}:${IMAGE_TAG}"
                }
            }
        }

        stage('Pushing to ECR') {
            steps {
                script {
                    sh "docker tag ${IMAGE_REPO_NAME}:${IMAGE_TAG} ${REPOSITORY_URI}:${IMAGE_TAG}"
                    sh "docker push ${REPOSITORY_URI}:${IMAGE_TAG}"
                }
            }
        }

  stage('Deploying to EC2') {
    steps {
        script {
            withCredentials([sshUserPrivateKey(credentialsId: JENKINS_CREDENTIALS_ID, keyFileVariable: 'SSH_KEY')]) {
                sh "scp -o StrictHostKeyChecking=no -i ${SSH_KEY} deploy_script.sh ubuntu@${EC2_INSTANCE_IP}:~/"
                sh "ssh -o StrictHostKeyChecking=no -i ${SSH_KEY} ubuntu@${EC2_INSTANCE_IP} 'bash -s' < ~/deploy_script.sh"
            }
        }
    }
}

    }
}







pipeline {
    agent any
    environment {
        AWS_DEFAULT_REGION = "us-east-1" 
        IMAGE_REPO_NAME = "phpappapplication"
        IMAGE_TAG = "latest"
         REPOSITORY_URI = "public.ecr.aws/r7u8p7a8/${IMAGE_REPO_NAME}"
    }
    
    stages {
        stage('Cloning Git') {
            steps {
                git branch: 'main', url: 'https://github.com/santoshbd67/phpapp.git' 
            }
        }
        
        // Building Docker images
        stage('Building image') {
            steps {
                script {
                    dockerImage = docker.build "${IMAGE_REPO_NAME}:${IMAGE_TAG}"
                }
            }
        }

        // Pushing Docker images to AWS ECR
        stage('Push to ECR') {
            steps {
                script {
                    // Tag the Docker image
                    sh "docker tag phpappapplication:latest public.ecr.aws/r7u8p7a8/phpappapplication:latest"

                    // Push the Docker image to ECR
                    sh "docker push public.ecr.aws/r7u8p7a8/phpappapplication:latest"
                }
            }
        }
    }
}

phpapp's People

Contributors

santoshbd67 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.