Skip to content

AnhaaD/hacknightvol4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions

Survey

https://docs.google.com/forms/d/e/1FAIpQLSd86H6ASEMG2FbgR-b1nuYsbECMUMJA3zjdt3vB2heo_F1SuA/viewform?fbclid=IwAR1QNNR7XDdm57CIjvOxLsPfTZQaUn8iwm5VME6GxpltyvLH1UAL4b6Aknw

fB- https://www.facebook.com/profile.php?id=100014595669198

Fork Repo https://github.com/anhaaD/hacknightvol4.git
git clone https://github.com/$YOURUSERNAME/hacknightvol4.git
cd hacknightvol4

Configure SSH on github

Generating a new SSH key

Open Terminal.


$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

$ pbcopy < ~/.ssh/id_rsa.pub
https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account


```bash

# Google cloud login
https://console.cloud.google.com/
# Create Api Credential
and Download .Json file
# create .circleCI config file
version: 2
jobs:
  build_and_test:
    docker:
      - image: circleci/node:10
    working_directory: ~/repo
    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-
      - run:
          name: Install dependencies
          command: npm install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run:
          name: Run tests
          command: npm test
      - store_test_results:
          path: test-results
  deploy_to_staging:
    docker:
      - image: google/cloud-sdk
    environment:
      - PROJECT_NAME: "hacknightvol4"  <----- Өөрчлөх
      - GOOGLE_PROJECT_ID: "united-tempest-228204"  // <----- Өөрчлөх
      - GOOGLE_COMPUTE_ZONE: "asia-east1-a" 
      - GOOGLE_CLUSTER_NAME: "hacknightvol4-cluster"  // <----- Өөрчлөх
    steps:
      - checkout
      - run: 
          name: Setup Google Cloud SDK 
          command: |
            apt-get install -qq -y gettext
            echo $GOOGLE_AUTH > ${HOME}/gcloud-service-key.json
            gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
            gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
            gcloud --quiet container clusters create ${GOOGLE_CLUSTER_NAME} --zone ${GOOGLE_COMPUTE_ZONE} 
            gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
            gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
            gcloud --quiet container clusters get-credentials ${GOOGLE_CLUSTER_NAME}
      - setup_remote_docker
      - run: 
          name: Docker build and  push
          command: |
            docker build \
              --build-arg COMMIT_REF=${CIRCLE_SHA1} \
              --build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` \
              -t ${PROJECT_NAME} .
            docker tag ${PROJECT_NAME} eu.gcr.io/${GOOGLE_PROJECT_ID}/${PROJECT_NAME}:${CIRCLE_SHA1}
            gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://eu.gcr.io
            docker push eu.gcr.io/${GOOGLE_PROJECT_ID}/${PROJECT_NAME}:${CIRCLE_SHA1}
      - run: 
          name: Deploy to Kubernetes
          command: |
            envsubst < ${HOME}/project/k8s.yml > ${HOME}/patched_k8s.yml
            kubectl apply -f ${HOME}/patched_k8s.yml
            kubectl rollout status deployment/${PROJECT_NAME}
workflows:
  version: 2
  build_test_deploy:
    jobs:
      - build_and_test
      - deploy_to_staging:
          requires:
            - build_and_test
          filters:
            branches:
              only: master
# Login CircleCI 
https://circleci.com/
# Browse Project From github

hacknightvol4
# ADD Variable on CircleCI 

Copy downloaded google credential and paste --> $GOOGLE_AUTH  

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published