Saturday, October 1, 2022

Loud fan of desktop

 Upon restart the fan of the desktop got loud again.


I cleaned the desktop from the dust but it was still loud (Lower than the first sound)

I tried to run nvidia-smi to see the temperature, couldnt see the driver

Tried to sudo apt update, didnt work

Tried to run sudo apt upgrade, worked

Ran sudo ubuntu-drivers devices

Then sudo ubuntu-drivers autoinstall

Didnt work

Then I just decided to remove all the nvidia drivers using

sudo apt-get remove --purge '^nvidia-.*'

sudo reboot

After reboot the noise was gone.


So it seems after reboot some of the drivers were upgraded which were not compatible.


Sunday, July 3, 2022

Gitlab CI/CD docker deployment

Source

(317) GitLab CI CD Tutorial for Beginners [Crash Course] - YouTube

.gitlab-ci.yml · main · Nana Janashia / gitlab-cicd-crash-course · GitLab



Main idea:

1. .gitlab-ci.yml will host the classical 3 stages which are

    a. test

    b. build

    c. deploy

2. build will use a docker image and service to build and push the docker image to docker hub

3. deploy will ssh to the target machine, kill existing docker image, run the specific docker image



variables:
  IMAGE_NAME: nanajanashia/demo-app
  IMAGE_TAG: python-app-1.0

stages:
  - test
  - build
  - deploy

run_tests:
  stage: test
  image: python:3.9-slim-buster
  before_script:
    - apt-get update && apt-get install make
  script:
    - make test


build_image:
  stage: build
  image: docker:20.10.16
  services:
    - docker:20.10.16-dind
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
  before_script:
    - docker login -u $REGISTRY_USER -p $REGISTRY_PASS
  script:
    - docker build -t $IMAGE_NAME:$IMAGE_TAG .
    - docker push $IMAGE_NAME:$IMAGE_TAG


deploy:
  stage: deploy
  before_script:
    - chmod 400 $SSH_KEY
  script:
    - ssh -o StrictHostKeyChecking=no -i $SSH_KEY root@161.35.223.117 "
        docker login -u $REGISTRY_USER -p $REGISTRY_PASS &&
        docker ps -aq | xargs docker stop | xargs docker rm &&
        docker run -d -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG"




Tuesday, June 14, 2022

ssh tunneling for closed ports

 

Source:

http://woshub.com/ssh-tunnel-port-forward-windows/



Problem: Some ports are blocked on the local machine by IT. Rather than asking to open ports, we use ssh tunneling to support the connection.


Assumption:

You can ssh to remote machine from the local machine using ssh user@ip


Approach:

Push the port connection through the ssh tunnel to access open ports



There are 3 modes of ssh tunneling


Local tunneling: When the local machine has IT restrictions but the remote is fine

Remote: Not yet sure what is the usecase for this


Local tunneling command


```

ssh -L 8888:10.247.2.145:7070 ubuntu@10.247.2.145

```

10.247.2.14: IP of the remote machine

7070 : Port that is opened on the remote server

8888: Local port that you will use to tunnel traffic.


After running the command above an ssh shell will open, we dont care about the shell


In the local browser open

127.0.0.1:8888


That's it





Sunday, March 13, 2022

Adding ssh keys to github

 To authenticate a connection from repository, you need to


1. Generate ssh keys in your machine

ssh-keygen -o -t rsa -C "your@email.com"

2. Copy the keys to github

Display the key

cat ~/.ssh/id_rsa.pub

Copy it to the ssh keys in github

3. Make sure the config files have the right url. Here is how it should look like. Make sure that the url has the structure shown below


[core]

        repositoryformatversion = 0

        filemode = true

        bare = false

        logallrefupdates = true

[remote "origin"]

        url = ssh://git@github.com:22/mohamedabolfadl/dubbizle_scraper.git

        fetch = +refs/heads/*:refs/remotes/origin/*

[branch "main"]

        remote = origin


Source

https://jdblischak.github.io/2014-09-18-chicago/novice/git/05-sshkeys.html


Setup the working space

 

1. Create anaconda environment

conda create --name scrappers --clone base


2. Activate environment

conda activate scrappers


3. Install key libs

$ conda config --add channels conda-forge
$ conda install cookiecutter
sudo apt-get install tree
Docker [Unverified] https://docs.docker.com/engine/install/ubuntu/
curl -fsSL https://get.docker.com -o get-docker.sh
DRY_RUN=1 sh ./get-docker.sh
4. Create cookiecutter project
mkdir defproj
cd defproj
cookiecutter -c v1 https://github.com/drivendata/cookiecutter-data-science
mkdir project_name
cd project_name
mkdir docker
5. Download Dockerfiles
curl -o Dockerfile https://raw.githubusercontent.com/mohamedabolfadl/default_docker_datascience/main/Dockerfile
cp Dockerfile project_name/docker/Dockerfile
curl -o project_name/docker/main.py https://raw.githubusercontent.com/mohamedabolfadl/default_docker_datascience/main/main.py


6. Initialize git repository [Not working at the push stage]
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/USERNAME/REPONAME.git
git remote -v
git remote set-url origin git@github.com:USERNAME/REPONAME.git
git push -u origin main

6. Run Docker
docker build -t scrapper .

docker run -it -p 8080:8080 --mount type=bind,source=/home/mohamed/Desktop/old/defproj,target=/app  scrapper




Loud fan of desktop

 Upon restart the fan of the desktop got loud again. I cleaned the desktop from the dust but it was still loud (Lower than the first sound) ...