Web Application of Laboratory of Modeling of Natural and Anthropogenic Disasters (LMNAD) from Nizhny Novgorod
These instructions for getting the copy of project in local machine for testing and development goals
- git
- linux
-
Clone project from github:
git clone [email protected]:arybin93/lmnad.git
-
Install python 3.7 Download Python 3.7 from python.org according to your OS.
-
Create virtual environment
python3.5 -m venv <directory_for_venv>
-
Install dependencies
pip install -r requirements.txt
For installing mysqlclient
-
Install MySQL Server 5.5.53 Example of instructions Create database
lmnad_db
, set your user and password inlmnad/project/settings/dev.py
-
Run migrate
# activate virtual environment # from project directory python manage.py migrate
This command create tables in your databases
-
Run server
python manage.py runserver
Check url from browser http://127.0.0.1:8000/
Project LMNAD without data was deployed locally, congratulations!
- Install Rabbit MQ
- Run celery with active venv and from root of project lmnad:
celery -A project worker -l info -P solo
Just for example of .env file (dev.env as example):
# https://docs.djangoproject.com/en/3.1/ref/settings/#std:setting-SECRET_KEY
DJANGO_SECRET_KEY=dev
# https://docs.djangoproject.com/en/3.1/topics/settings/#designating-the-settings
DJANGO_SETTINGS_MODULE=project.settings.server
# Database connection (MySQL)
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DB_HOST=db # HOST
DB_USER=dev # USER
DB_PASSWORD=dev # PASSWORD
# Celery broker settings Rabbit MQ
# https://docs.celeryproject.org/en/master/getting-started/backends-and-brokers/rabbitmq.html#installation-configuration
CELERY_BROKER_URL=amqp://guest:guest@broker:5672 # Broker
CELERY_RESULT_BACKEND=rpc:// # Backend
# Credentials for MySQL container
MYSQL_ROOT_HOST=%
MYSQL_ROOT_PASSWORD=root
# Usign Yandex Translate https://yandex.com/dev/translate/
YANDEX_TRANSLATE_API_KEY=base
# https://developers.google.com/maps/documentation/javascript/get-api-key
# For using Google Map in admin panel
GEOPOSITION_GOOGLE_MAPS_API_KEY=base
Prepare .env file or env variables on host and run
docker-compose up -d
with building if required
docker-compose up -d --build
Prepare .env file or env variables on host and run
docker-compose -f docker-compose.dev.yml up -d --build
Run migration manually or restore DB dump
docker exec -ti lmnad_web_dev bash
# and then run manually
python manage.py migrate
Check url from browser http://127.0.0.1:8001/
Project LMNAD without data was deployed locally, congratulations!
If you need data from site LMNAD locally (for testing and development goals),
send request for getting data to [email protected]
- Unzip
gzip -d backup_22_11_2020.sql.gz
- Copy to mysql container (for dev
lmnad_mysql_dev
)docker cp backup_22_11_2020.sql lmnad_mysql:/tmp
- Run SQL script
docker exec -ti lmnad_mysql bash mysql -u root -p lmnad_db < /tmp/backup_22_11_2020.sql
- Copy backup to container
docker cp backup.lmnad_uploads_22_11_2020.tar.gz lmnad_web:/tmp
- Go to container and Unzip
docker exec -ti lmnad_web bash cd /tmp tar -xvf backup.lmnad_uploads_22_11_2020.tar.gz
- 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
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
- Generate message
docker exec -ti lmnad_web_dev bash python manage.py makemessages -l ru
- Put translation in
locale
folder - Run compile messages
python manage.py compilemessages