Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

NERSC Deployment

Felipe Machado edited this page Mar 8, 2019 · 6 revisions

Example based on felipelm account at NERSC

Build Locally and Push

framework/.env edit:

REACT_APP_OFFLINE=true
REACT_APP_VERSION=v0.7.1

Nginx conf (frontend/nginx-proxy.conf):

upstream api {
    server app:8000;
}

server {
    listen 8080;
    location /dashboard/ {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_pass http://api$request_uri;
    }

    location /static/rest_framework/ {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_pass http://api$request_uri;
    }

    location ~* (service-worker\.js)$ {
        add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        expires off;
        proxy_no_cache 1;
    }

    location / {
      root /var/www/frontend;
      try_files $uri $uri/ /index.html;
    }

}

Frontend build and push:

docker-compose build nginx
docker tag qlf_nginx:latest registry.spin.nersc.gov/felipelm/nginx:1.6
docker push registry.spin.nersc.gov/felipelm/nginx:1.6

Backend build and push: make sure you have docker-compose.yml in your qlf folder and removed backend/spectro folder

docker-compose build app
docker tag qlf_app:latest registry.spin.nersc.gov/felipelm/qlf_backend:1.5
docker push registry.spin.nersc.gov/felipelm/qlf_backend:1.5

Example docker-compose.yml deployment file:

version: '2'
services:
  app:
    image: registry.spin.nersc.gov/felipelm/qlf_backend:1.5
    user: 75605:58102
    environment:
      - LOGS_DIRECTORY=False
      - QLF_API_URL=http://localhost:8000/dashboard/api
      - QLF_BASE_URL=http://localhost:8000
      - QLF_HOSTNAME=*
      - QLF_PORT=8000
      - EMAIL_USE_TLS = False
      - EMAIL_HOST=localhost
      - EMAIL_PORT=25
      - EMAIL_HELPDESK=LIneA Science Server <[email protected]>
      - UPDATE_DEPENDENCIES=False
      - RUN_DB_MIGRATIONS=False
      - POSTGRES_PASSWORD_FILE=/run/secrets/qlf-db-pw
      - POSTGRES_USER=quicklook
      - POSTGRES_DB=desi_dev
      - POSTGRES_PORT=60042
      - POSTGRES_OPTIONS=-c search_path=qlf
      - DB_NAME=db.replicator.dev-cattle.stable.spin.nersc.org
      - PIPELINE_ARMS=b
      - PIPELINE_SPECTROGRAPHS=0 # e.g. 0,1,2,3,4,5,6,7,8,9
      - PIPELINE_LOGLEVEL=INFO
      - PIPELINE_MAX_WORKERS=0
      - PIPELINE_DELAY=20
    working_dir: /app/
    ports:
      - "60050:8000"
    command: ./run.sh # script that runs on docker-compose up
    cap_drop:
      - ALL
    secrets:
    - mode: '0444'
      uid: '75605'
      gid: '75605'
      source: db.qlf.qlf_db_pw 
      target: qlf-db-pw
  web:
    image: registry.spin.nersc.gov/felipelm/nginx:1.6
    ports:
      - "60049:8080"
    user: 75605:58102
    group_add:
    - nginx
    cap_drop:
    - ALL

secrets:
  db.qlf.qlf_db_pw:
    external: true

Rancher Deploy

you must be inside the docker-compose.yml directory

e.g. cd /global/project/projectdirs/desi/users/felipelm/qlf

Configure the environment

module load spin

Sandbox

export RANCHER_ENVIRONMENT=sandbox

Production

export RANCHER_ENVIRONMENT=prod-cattle

Change docker-compose.yml to the appropriate version and deploy using:

rancher up -d --upgrade --confirm-upgrade

To get the endpoint assigned run:

rancher inspect qlf/web | jq '.publicEndpoints'

takes about 15 minutes to update the deployment DNS