Skip to content

MVIS-Team/MVISGuidance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MVISGuidance

Usage

Administration

Set user(s) as teacher

  1. Login to Django's administration page.
  2. Select Authentication and AuthorizationUsers.
  3. Select users using checkbox.
  4. Select Action Set user as teacher.
  5. Click Go.

Deployment

Installation

  1. Clone the repository

    git clone https://github.com/MVISGuidance/production MVISGuidance
    cd MVISGuidance/
  2. Setup environment variables (.env) if necessary.

    DJANGO_SETTINGS_MODULE = "main.setting.production"
    DJANGO_SECRET_KEY = "<django secret key>"
    DJANGO_HOSTNAME = "<deployment url>"
    EMAIL_HOST = "<email host>"
    EMAIL_HOST_USER = "<username for email host>"
    EMAIL_HOST_PASSWORD = "<password for email host>"
  3. Setup and activate virtual environment with virtualenv.

    python -m virtualenv venv
    source venv/bin/activate
    pip install -r requirements.txt
  4. Setup Django

    python manage.py collectstatic
    python manage.py migrate
  5. Setup gunicorn service (/etc/systemd/system/MVISGuidance.service).

    [Unit]
    Description=gunicorn daemon
    After=network.target
    
    
    [Service]
    User=root
    Group=www-data
    WorkingDirectory=<path to project>/backend
    ExecStart=<path to project>/venv/bin/gunicorn \
              --access-logfile - \
              --workers 3 \
              --bind unix:/run/MVISGuidance.sock \
              main.wsgi:application
    
    [Install]
    WantedBy=multi-user.target
    
  6. Setup gunicorn socket (/etc/systemd/system/MVISGuidance.socket).

     [Unit]
     Description=gunicorn socket
    
     [Socket]
     ListenStream=/run/MVISGuidance.sock
    
     [Install]
     WantedBy=sockets.target
    
  7. Enable the gunicorn and check its status.

    sudo systemctl daemon-reload
    sudo systemctl start MVISGuidance
    sudo systemctl enable MVISGuidance
    sudo systemctl status MVISGuidance
  8. Setup nginx (/etc/nginx/sites-available/MVISGuidance).

    server {
        listen 80;
        server_name '<server's IP address>';
    
        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /var/www/MVISGuidance;
        }
        location /media/ {
            root /var/www/MVISGuidance;
        }
    
        location / {
            include proxy_params;
            proxy_pass http://unix:/run/MVISGuidance.sock;
        }
    }
  9. Enable nginx and check status.

    sudo ln -s /etc/nginx/sites-available/MVISGuidance /etc/nginx/sites-enabled
    sudo nginx -t
  10. Restart nginx and open up the firewall to normal traffic on port 80

    sudo systemctl restart nginx
    sudo ufw allow 'Nginx Full'

Update

  1. Update packages.

    sudo apt-get update
    sudo apt-get upgrade
  2. Move to the project folder and activate virtual environment.

    cd MVISGuidance/
    source venv/bin/activate
  3. Pull the update.

    git pull https://github.com/MVISGuidance/production
  4. Setup environment variables (.env) if necessary.

  5. Update requirements and setup django.

    pip install -r requirements.txt
    python backend/manage.py collectstatic
    python backend/manage.py migrate
  6. Restart gunicorn

    sudo systemctl daemon-reload
    sudo systemctl restart MVISGuidance

Additional Resources

Contributing

See Contributing Guideline for more details.