Skip to content

Latest commit

 

History

History
146 lines (121 loc) · 4.64 KB

File metadata and controls

146 lines (121 loc) · 4.64 KB

Setup for the CleanApp developer

Configuring SSH access to VMs

This configuration is to be done once.

  1. Generate an SSH keys pair

    ssh-keygen -t rsa -f .ssh/<you>-cleanapp-io -C <you>
    
  2. Upload a public key to Google cloud

    gcloud compute os-login ssh-keys add --key-file=.ssh/<you>-cleanapp-io.pub
    
  3. Set up the dev machine

    • Login to the dev VM with SSH
      ssh -i ~/.ssh/<you>-cleanapp-io <you>_cleanapp_io@34.132.121.53
      
    • Grant ssh permission to the deployer account
      sudo nano /home/deployer/.ssh/authorized_keys
      
      Add the previously generated public key to the end of the file.
    • Login as deployer to check that it works
      ssh -i ~/.ssh/<you>-cleanapp-io deployer@34.132.121.53
      
  4. Set up prod machine

    • Same as dev machine, just use the IP address 34.122.15.16

Deploying the CleanApp component

Here is a deployment documentation. Using the frontend deployment as an example.

  1. Clone the frontend repository.

    git clone https://github.com/cleanappio/cleanapp-frontend.git
    
  2. Make your changes.

Dev deployment

Run the build & deploy script.

./build_image.sh -e dev --ssh-keyfile ~/.ssh/<you>-cleanapp-io

Production deployment

Run the build & deploy script.

./build_image.sh -e prod --ssh-keyfile ~/.ssh/<you>-cleanapp-io

Setting up a new CleanApp VM

  1. Enable OS login on VMs

  2. Configure the deployer user

    1. Login to the VM as yourself, either via Cloud SSH or using its external IP address with your key.

      ssh -i .ssh/<you>-cleanapp-io <you>_cleanapp_io@<VM IP address>
      
    2. Create the deployer user.

      groupadd deployer -g 1003
      useradd deployer -u 1003 -g 1003 -m -s /bin/bash
      

      No need for the password as we will use SSH keys for login.

    3. Configure passwordless sudo for deployer.

      • Run the sudo visudo
      • Add the following line after the %sudo ALL=(ALL:ALL) ALL
        deployer ALL=(ALL) NOPASSWD:ALL
        
      • Save changes
    4. Enable users for logging in as deployer.

      • Add public SSH keys of all users you want to grant permission to into the file /home/deployer/.ssh/authorized_keys
        sudo mkdir /home/deployer/.ssh
        sudo touch /home/deployer/.ssh/authorized_keys
        sudo mcedit /home/deployer/.ssh/authorized_keys
        
      • Set proper permissions
        sudo chown -R deployer:deployer /home/deployer/.ssh
        sudo chmod 700 /home/deployer/.ssh
        sudo chmod 600 /home/deployer/.ssh/authorized_keys
        
    5. Login to the VM as deployer

      ssh -i .ssh/<you>-stxn-cloud deployer@<VM IP address>
      
    6. Configure the deployer for docker communications

      gcloud auth configure-docker us-central1-docker.pkg.dev
      

      That will create a configuration file .docker/config.json.

    7. Configure the service account

      gcloud config set account cleanapp@cleanup-mysql-v2.iam.gserviceaccount.com
      
    8. Activate the service account

      • Generate a new keypair for the account (from your personal authenticated account with iam permissions)
        $ gcloud iam service-accounts keys create ~/cleanapp-mysql-v2-key.json \
        --iam-account=cleanapp@cleanup-mysql-v2.iam.gserviceaccount.com
        $ scp ./cleanapp-mysql-v2-key.json deployer@<host>:/home/deployer/cleanapp-mysql-v2-key.json
        
      • Copy the keypair file to the VM
      • Activate the account
        gcloud auth activate-service-account cleanapp@cleanup-mysql-v2.iam.gserviceaccount.com --key-file=cleanapp-mysql-v2-key.json
        
      • Delete the keypair file after activation

Installing Docker

  1. Copy the installing script to the VM
    scp -i ~/.ssh/eko-cleanapp-io setup/install_docker.sh deployer@34.132.121.53:install_docker.sh
    
  2. Login to the VM and run the install script
    ssh -i ~/.ssh/<you>-cleanapp-io deployer@34.132.121.53
    
    chmod a+x ./install_docker.sh
    ./install_docker.sh
    
  3. Add the deployer to the docker group
    sudo usermod -aG docker $USER
    
  4. Logout from the VM and login again