Skip to content

rohanbas95/cdac

Repository files navigation

Git Commands

list of important git commands

  1. git init
  2. git status
  3. git add .
  4. git commit
  5. git commit -am "COMMIT_MSG_HERE"
  6. git log
  7. git pull

  1. git branch -l
  2. git branch -D BRANCH_NAME
  3. git checkout BRANCH_NAME
  4. git checkout -B BRANCH_NAME

  1. git stash
  2. git stash pop
  3. git stash push
  4. git stash list

  1. git merge BRANCH_NAME
  2. git cherry-pick COMMIT_SHA

  1. git pull --rebase
  2. git pull --no-rebase

  1. git reset --soft COMMIT_SHA
  2. git reset --hard COMMIT_SHA
  3. git push --force

Vim Commands

  1. gg - Go to the first line of the file
  2. G - Go to the last line of the file
  3. 5G - Go to line number 5
  4. ff - Find file (in some Vim configs, or use / for search)
  5. p - Paste after the cursor
  6. dd - Delete the current line
  7. :w - Save (write) the file
  8. :q - Quit Vim
  9. :!q - Force quit Vim (discard changes)
  10. :set number - Show line numbers in the editor

vim has three modes

  1. command mode
  2. insert mode
  3. extended mode

Github action

setting up basic CI CD pipeline using github action few keypoints to note

  1. github action runner
  2. branch protection
  3. github secrets ${{ secrets.ORG_GITHUB_PACKAGES_READER }}

refer below example

name: PR Build #name of the workflow
on: # the trigger on which to run workflow
  push:  
    branches: [main, "fix/*", "feat/*"]
    paths: 
      - 'frontend/**'
  pull_request:
    branches: [main, "fix/*", "feat/*"]
    paths: 
      - 'frontend/**'
  workflow_dispatch:

env:
  NODE_VERSION: 20

jobs:
  pr-build-api:
    runs-on: ubuntu-latest
    steps:
      - name: 🐙 Checkout code
        uses: actions/checkout@v4

      - name: 🔥 Setup NodeJS
        uses: actions/setup-node@v4
        with:
          registry-url: "https://npm.pkg.github.com"
          always-auth: true
          node-version: ${{ env.NODE_VERSION }}

      - name: 🏗️ Build FrontEnd
        working-directory: ./frontend
        run: |
          npm install
          npm run build

how to run project locally

  1. open three terminals
  2. in each terminal cd to folder frontend , product-service, user-service
  3. run brew services start mongodb/brew/mongodb-community in new terminal
  4. run npm install , npm run build and npm run start in each terminal
  5. website will be live on http://localhost:3000/

how to install mongoDB on mac

  1. brew tap mongodb/brew
  2. brew install mongodb-community
  3. brew install mongosh
  4. brew services start mongodb/brew/mongodb-community

how to install mongoDb on windows

refer

Important Note: If you are running MongoDB in Docker, make sure your local MongoDB service is stopped. Running both at the same time can cause port conflicts and connection issues. brew services stop mongodb/brew/mongodb-community

docker commands

  1. docker ps | docker ps -a
  2. docker run -e POSTGRES_PASSWORD=password postgres:9.6
  3. docker pull redis
  4. docker run redis
  5. docker run -d redis
  6. docker images
  7. docker start f32897c3b1c9
  8. docker stop f32897c3b1c9

  1. docker run -p6000:6379 -d redis
  2. docker logs older
  3. docker run -p6002:6379 -d --name older redis
  4. docker exec -it afd05d2c05f6 /bin/bash

  1. docker pull mongo
  2. docker pull mongo-express
  3. docker network ls
  4. docker network create mongo-network
docker run -d \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
--name mongodb \
--net mongo-network \
mongo
docker run -d \
-p 8081:8081 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=password \
--net mongo-network \
--name mongo-express \
-e ME_CONFIG_MONGODB_SERVER=mongodb \
mongo-express
  1. docker-compose -f docker-compose.yaml up -d
  2. docker-compose -f docker-compose.yaml down
  3. docker build -t my-prod:1.2 .

  1. docker system prune -f # Remove all unused containers, networks, images (not just dangling ones), and optionally, volumes
  2. docker image prune -a -f # Remove all unused images
  3. docker container prune -f # Remove all stopped containers
  4. docker rm $(docker ps -a -q) # Remove all stopped containers
  5. docker rmi $(docker images -q) # Remove all images

setup docker on ec2

sudo dnf update -y
sudo dnf install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
sudo rm /usr/local/bin/docker-compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -aG docker $USER
groups $USER
sudo systemctl restart docker

make sure to open a new cli session after running the above docker install commands

install git on linux 2023

'sudo dnf install git -y'

make sure to login docker on ec2

aws configure aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 504584570834.dkr.ecr.us-east-1.amazonaws.com

Basic Mongo Shell Commands

Command Description
show dbs List all databases
use mydb Switch to (or create) database mydb
show collections List all collections in the current database
db.createCollection('users') Create a new collection named users
db.users.insertOne({ name: 'John', age: 30 }) Insert a single document into users
db.users.insertMany([{ name: 'Alice' }, { name: 'Bob' }]) Insert multiple documents
db.users.find() Show all documents in users
db.users.find({ name: 'John' }) Find documents with name 'John'
db.users.deleteOne({ name: 'John' }) Delete one document with name 'John'
db.users.deleteMany({}) Delete all documents in users
db.users.updateOne({ name: 'John' }, { $set: { age: 31 } }) Update a document
db.dropDatabase() Drop the current database
db.users.drop() Drop the users collection

to create ssh keygen public from pem

ssh-keygen -y -f /Users/rohanbasankar/Downloads/cdacdevops.pem > /Users/rohanbasankar/Downloads/cdacdevops.pub

terraform commands

Command Description
terraform init Initialize a Terraform working directory
terraform plan Show changes that will be made by Terraform
terraform apply Apply the planned changes to your infrastructure
terraform destroy Destroy the Terraform-managed infrastructure
terraform validate Validate the Terraform files for syntax errors
terraform output Show output values from your Terraform state

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors