DevOps Training
  • DevOps
  • What is DevOps
    • What DevOps Look like
    • Why DevOps Needed
    • DevOps Automation Tools
    • DevOps Principles
  • cloud computing
    • How DevOps links with Cloud Computing
    • What is cloud computing?
      • Platform as a service (PaaS)
      • Infrastructure as a service (IaaS)
      • Software as a service (SaaS)
      • Function as a Service
      • SaaS, PaaS, IaaS
  • Version Control
    • Git as Version Control
      • Setting up Remote Repo
      • Git Hooks
      • github vs gitlab vs bitbucket
      • Quick Recap Git
  • DevOps #01 Continuous Integration
    • Continuous Integration & Continuous Delivery
      • Understanding CI Tools
      • Prerequisite
      • Continuous Integration
      • CI Tools
      • Travis-CI
        • Travis CI with S3
        • Static Site Build S3
        • Beanstalk with AWS CLI
          • Elastic Beanstalk with Travis CI
        • Travis using Code Deploy EC2
          • Github and Code Deploy
          • Travis CI with Code Deploy
      • Gitlab-CI
        • CI Setup for application
        • Gitlab Runners on EC2
        • CI Integration with AWS
          • Deploying App using Gitlab CI
          • Gitlab CI with AWS S3
          • Gitlab CI with ECS
          • CI Integration with EC2
            • Update and Clean Gitlab.yml
        • Install Gitlab on EC2
      • CI/CD using Jenkins CI
        • Jenkins Build on EC2
        • Jenkins Build EC2 Ubuntu
        • Jenkins CI/CD
          • Create a Build Item
          • Create a Build Pipleine
            • Pipeline Using Docker
            • Pipeline Examples
          • Jenkins CI with S3
            • Jenkins CI - S3
          • Jenkins CI with EC2
    • Jenkins CI Cluster Mode
    • AWS Code Pipeline CI/CD
      • AWS CI/CD Tools
        • AWS Code Build
        • AWS Code Deploy to Beanstalk
        • AWS Code Deploy to EC2
        • AWS Pipeline - Example CI/CD
  • Docker
    • Docker
      • Docker for Developers
        • Install and setup
        • Docker Commands
        • Docker Images Container
        • Docker Architecture
    • Docker Demos
      • Node JS Container
    • Docker-compose
      • Using Docker Compose
      • Docker Compose Demo
  • AWS Quick Refresh
    • AWS Quick Recap - Videos
    • AWS Quick Recap
  • AWS Architecture - Lab
    • Application Deployment - 01
    • Application Deployment - 02
    • Application 3 tier Architecture
  • Basic Networking
    • Computer Networking for Beginners
      • Basic of Networking
      • Networking Protocols
      • OSI Model
      • Network address and Host address
      • Subnetting Type
    • Network Architecture
    • Networking Layers OSI Model
    • Internet protocol
      • CIDR and subnetting
        • Examples
      • AWS VPC Subnets
  • VPC and Networking
    • AWS VPC
    • VPC Demo
      • Bastion Host | Jump Server
  • AWS Components
    • AWS Components In Depth
      • AWS Storage
        • AWS EBS
        • AWS Cloudfront
        • AWS S3
      • AWS Compute
        • ECS
        • AWS VPC
          • VPC Components
        • AWS EC2
        • AWS ELB
          • Application Load balancer
            • Example
        • AWS EC2 Auto Scaling
          • Demo
        • AWS Route 53
        • AWS Lambda Serverless
          • AWS Lambda Serverless Computing
  • Assignments
    • Assignment 01-Node JS app on EC2
    • Assignment 02-Node JS with Mysql
    • Assignment-03
  • Microservices
    • Microservices Architecture
      • Docker and Docker-Compose
      • Docker-Compose Example 01
      • Docker-Compose Example 02
      • Hand-on | Building Microservices
    • Architecture Components
  • AWS ECS
    • AWS ECS
      • Introduction of ECS
Powered by GitBook
On this page

Was this helpful?

  1. Version Control
  2. Git as Version Control

Setting up Remote Repo

setting up git remote Repo

PreviousGit as Version ControlNextGit Hooks

Last updated 5 years ago

Was this helpful?

Sign in if you have account, if not make one

3. Click on EC2

4. Click on Launch Instance

5. Select Ubuntu

6. Select Free Tier t2 micro

7. Configure Instance Details

8. Add Storage if you need it

9. Add a tag if you want to

10. Launch your instance

11. Create a key pair and make sure to save it somewhere safe. You won’t be able to replace it.

12. Launch the instance. Done!, Now we can ssh to this instance

       __| __|_  )       _| (   / Amazon Linux AMI      ___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/
chmod 400 key.pem
ssh -i key.pem ec2-user@x.x.x.x // get piblic ip of system 
# exit from server now we are able to ssh to remote server 
# now add local public key to server  [Important step]
cat ~/.ssh/id_rsa.pub | ssh -i  key.pem  ec2-user@x.x.x.x "cat>> .ssh/authorized_keys"

ssh -i key.pem ec2-user@x.x.x.x
# enter to the remote system console 
mkdir app.git
cd app.git
git init --bare

So not much going on here, all we do is create an empty repository and then leave. Now, on the local machine, you do something like the following:

Access remote repo :

.ssh >  git clone ssh://ec2-user@x.x.x.x/home/ec2-user/app.git
Cloning into 'myproject'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
 git:(master) git remote -v
origin ssh://ec2-user@x.x.x.x/home/ec2-user/app.git (fetch)
origin ssh://ec2-user@x.x.x.x/home/ec2-user/app.git (push)

Create POST Receive Hook

Crate POST receive push Hook
chmod +x hooks/post-receive
chmod +x hooks/post-receive
GIT_WORK_TREE=/home/ec2-user/myproject
export GIT_WORK_TREE
git checkout -f
cd /home/ec2-user/myproject
sudo npm install
forever start app.js

Here we go.. we are able to setup bare repo on server and accessing it from application containers.