git initgit statusgit add .git commitgit commit -am "COMMIT_MSG_HERE"git loggit pull
git branch -lgit branch -D BRANCH_NAMEgit checkout BRANCH_NAMEgit checkout -B BRANCH_NAME
git stashgit stash popgit stash pushgit stash list
git merge BRANCH_NAMEgit cherry-pick COMMIT_SHA
git pull --rebasegit pull --no-rebase
git reset --soft COMMIT_SHAgit reset --hard COMMIT_SHAgit push --force
gg- Go to the first line of the fileG- Go to the last line of the file5G- Go to line number 5ff- Find file (in some Vim configs, or use/for search)p- Paste after the cursordd- Delete the current line:w- Save (write) the file:q- Quit Vim:!q- Force quit Vim (discard changes):set number- Show line numbers in the editor
- command mode
- insert mode
- extended mode
setting up basic CI CD pipeline using github action few keypoints to note
- github action runner
- branch protection
- 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- open three terminals
- in each terminal
cdto folder frontend , product-service, user-service - run
brew services start mongodb/brew/mongodb-communityin new terminal - run
npm install,npm run buildandnpm run startin each terminal - website will be live on http://localhost:3000/
- brew tap mongodb/brew
- brew install mongodb-community
- brew install mongosh
- brew services start mongodb/brew/mongodb-community
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 ps|docker ps -adocker run -e POSTGRES_PASSWORD=password postgres:9.6docker pull redisdocker run redisdocker run -d redisdocker imagesdocker start f32897c3b1c9docker stop f32897c3b1c9
docker run -p6000:6379 -d redisdocker logs olderdocker run -p6002:6379 -d --name older redisdocker exec -it afd05d2c05f6 /bin/bash
docker pull mongodocker pull mongo-expressdocker network lsdocker 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
docker-compose -f docker-compose.yaml up -ddocker-compose -f docker-compose.yaml downdocker build -t my-prod:1.2 .
docker system prune -f# Remove all unused containers, networks, images (not just dangling ones), and optionally, volumesdocker image prune -a -f# Remove all unused imagesdocker container prune -f# Remove all stopped containersdocker rm $(docker ps -a -q)# Remove all stopped containersdocker rmi $(docker images -q)# Remove all images
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 dockermake sure to open a new cli session after running the above docker install commands
'sudo dnf install git -y'
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
| 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 |
ssh-keygen -y -f /Users/rohanbasankar/Downloads/cdacdevops.pem > /Users/rohanbasankar/Downloads/cdacdevops.pub
| 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 |