Skip to content

nnstu-appmath/lmnad

Repository files navigation

LMNAD project

Build Status

Web Application of Laboratory of Modeling of Natural and Anthropogenic Disasters (LMNAD) from Nizhny Novgorod

Getting Started

These instructions for getting the copy of project in local machine for testing and development goals

Installation prerequisites and knowledge/skills required

  • git
  • Docker (We use docker containers for production and dev environment)
  • Python, Django

Setting up project via Docker

  1. Clone project from github:

    git clone git@github.com:nnstu-appmath/lmnad.git
    

    Project will be migrated soon from original git@github.com:arybin93/lmnad.git

  2. Create .env file in root of project (see dev.env as example)

Production (with SSL cert, nginx)

  1. Run docker-compose:
    docker-compose up -d 
    
    with building if required
    docker-compose up -d --build
    

Production (local, without SSL cert)

  1. Run docker-compose:
    docker-compose -f docker-compose.prod.local.yml up -d --build
    

Development (local)

Simplified docker-compose configuration specially for development

  1. Run docker-compose:

    docker-compose -f docker-compose.dev.yml up -d --build
    
  2. Check containers status and check url from browser http://127.0.0.1:8000/

  3. Run migration manually or restore DB dump and media from backup

  docker exec -ti lmnad_web_dev bash
  python manage.py migrate

Setting up Database and media

If you need data from site LMNAD locally (for testing and development goals),
send request for getting data to arybin93@email.com

Restore DB backup

  1. Unzip
    gzip -d backup_22_11_2020.sql.gz
    
  2. Copy to mysql container (for dev lmnad_mysql_dev)
    docker cp backup_22_11_2020.sql lmnad_mysql:/tmp
    
  3. Run SQL script
    docker exec -ti lmnad_mysql bash
    mysql -u root -p lmnad_db < /tmp/backup_22_11_2020.sql
    

Restore media Backup

  1. Copy backup to container
    docker cp backup.lmnad_uploads_22_11_2020.tar.gz lmnad_web:/tmp
    
  2. Go to container and Unzip
    docker exec -ti lmnad_web bash
    cd /tmp
    tar -xvf backup.lmnad_uploads_22_11_2020.tar.gz
    
  3. Copy to folder /lmnad/project/media
    cd /tmp/var/www/site/lmnad/project/media
    cp -r uploads/ /lmnad/project/media/
    rm -rf backup.lmnad_uploads_22_11_2020.tar.gz
    rm -rf /tmp/var
    

Setup https

According to article

docker run -t --rm -v lmnad_certs:/etc/letsencrypt -v lmnad_certs_data:/data/letsencrypt deliverous/certbot renew --webroot --webroot-path=/data/letsencrypt
docker-compose kill -s HUP nginx

Translation

Django translation

  1. Generate message docker exec -ti lmnad_web_dev bash python manage.py makemessages -l ru
  2. Put translation in locale folder
  3. Run compile messages python manage.py compilemessages

Setting up project (without docker)

  1. Clone project from github:

    git clone git@github.com:arybin93/lmnad.git
    
  2. Install python 3.7 Download Python 3.7 from python.org according to your OS.

  3. Create virtual environment

    python3.7 -m venv <directory_for_venv>
    
  4. Install dependencies

    pip install -r requirements.txt
    

    For installing mysqlclient

  5. Install MySQL Server 5.5.53 Example of instructions Create database lmnad_db, set your user and password in lmnad/project/settings/dev.py

  6. Run migrate

    # activate virtual environment
    # from project directory
    python manage.py migrate
    

    This command create tables in your databases

  7. Run server

    python manage.py runserver
    

    Check url from browser http://127.0.0.1:8000/

Project LMNAD without data was deployed locally, congratulations!

Running celery worker

  1. Install Rabbit MQ
  2. Run celery with active venv and from root of project lmnad:
    celery -A project worker -l info  -P solo