Skip to content

Local-Connectivity-Lab/ccn-coverage-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo serves these purposes:

  • Sharing an instruction for the development environment setup.
  • Enabling reproducible and easy deployments to staging and production environments.
    • We leave the version unspecified for some dependencies (namely system dependencies, installed via apt). This is ok, but we should be explicit about doing this.
    • Git history records the past working versions on production. It helps us revert to old deployments in case of problems.

Development environment

  1. If your host OS is Windows, install WSL 2 and Linux. All below instructions are run in a Linux or Mac.
  2. Prepare your ssh key. To generate a new key, see here. If your host OS is Windows, copy your key(s) between the host Windows and the guest Linux.
  3. Set up your GitHub account with your SSH key.
  4. Install a node version manager, e.g. nvm.
  5. Below, if you're developing the vis only, skip database and api.
  6. First-time setup
    1. Database
      • Option 1: docker
        1. Install docker.
        2. Dump the test data into MongoDB.
          cd ccn-coverage-deploy/
          docker compose run --rm \
              -v "${PWD}/assets/dev/mongo-data-mock:/mongo-data-mock" \
              mongo \
              /mongo-data-mock/initialize.sh
      • Option 2: mongo version manager
        • There are several tools for this. Search online for the most up-to-date recommendations.
    2. Api
      cd your-development-dir/
      git clone [email protected]:Local-Connectivity-Lab/ccn-coverage-api.git
    3. Vis
      cd your-development-dir/
      git clone [email protected]:Local-Connectivity-Lab/ccn-coverage-vis.git
  7. Bringup & Teardown
    1. Database
      • Option 1: docker
        1. Bringup:
          cd ccn-coverage-deploy/
          docker compose up -d
        2. Teardown:
          cd ccn-coverage-deploy/
          docker compose down
    2. Api
      1. Bringup:
        cd ccn-coverage-api/
        nvm use
        npm start
      2. Teardown: Ctrl + c
    3. Vis
      1. Bringup:
        cd ccn-coverage-vis/
        nvm use
        npm start
        # If you want vis to talk to your local api, specify the below environment variable.
        # REACT_APP__API_URL='http://localhost:3000' npm start
      2. Teardown: Ctrl + c

Staging and Production environments

Fist-time setup:

  1. Provision a compute instance on cloud.
    • CPUs = 1
    • Memory = 2GB
  2. Your local environment should be configured with an ssh key that authorizes you on GitHub and on the remote environment. In addition, every time you ssh into a remote environment (staging or production), you want to "forward" your local ssh key there. To do so:
    1. Edit your ~/.ssh/config. Add these lines:
      Host *.seattlecommunitynetwork.org
          ForwardAgent yes
      
    2. Edit your shell configuration file: ~/.bashrc on Linux or ~/.zshrc on Mac. Add these lines. (This may be optional, but is likely needed on a WSL Linux.)
      if [ -z "$SSH_AUTH_SOCK" ] ; then
          eval `ssh-agent -s`
          ssh-add
      fi
  3. Ansible depends on python. Install a python version manager, e.g. pyenv. Then, install a python runtime: e.g. pyenv install 3.11.
  4. Install ansible (pip install ansible).
  5. Copy Api's keys to here.

Do deploy:

  1. Back up data.
    1. ssh <environment>.seattlecommunitynetwork.org
    2. At the remote environment:
      cd /tmp/
      rm -r ./dump.tgz ./dump/
      mongodump
      tgz -zxf ./dump.tgz ./dump/
    3. Upload the dump.tgz to our Google Drive.
    4. At the remote environment:
      rm -r /tmp/.dump.tgz /tmp/dump/
  2. Configure a target environment via Ansible.
    cd ccn-coverage-deploy/
    ansible-playbook -i ./environments/staging ./playbook.yaml
  3. Commit whatever changes you made to this ccn-coverage-deploy repo, and push it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages