Skip to content

Latest commit

 

History

History
130 lines (70 loc) · 3.08 KB

README.md

File metadata and controls

130 lines (70 loc) · 3.08 KB

LABCOMP App

Build Status

Requirements

Install and configure Docker

  1. Install docker. Docker

  2. Intall docker-compose. Compose

Set Var Environment

  1. Copy to env.example into .env

     cp env.example .env
    
  2. Edit values in .env

     nano .env
    
  3. Config domain

     echo "127.0.1.1 dev.labcomp.com" | sudo tee -a /etc/hosts > /dev/null
    

BackEnd

  1. Start container DB

     docker-compose up -d mysql
    
  2. Apply migrations

     docker-compose run --rm django python manage.py migrate
    
  3. Run Django Project

     docker-compose up -d
    
  4. Open project on browser

     http://dev.labcomp.com:8000
    

Django Admin

  1. Create superuser (Execute command and follow the steps)

     docker-compose run --rm django python manage.py createsuperuser
    
  2. Access to django admin

     http://dev.labcomp.com:8000/admin/
    

Run tests to code

  1. Exit instantly on first error or failed test

     docker-compose run --rm -e TEST=true django py.test -x accounts/tests.py
    
  2. Activate the Python Debugger

     docker-compose run --rm -e TEST=true django py.test --pdb accounts/tests.py
    
  3. Run all the tests

     docker-compose run --rm -e TEST=true django py.test
    

Run tests to style

  1. Run tests isort

     docker-compose run --rm django isort -c -rc -df
    
  2. Run tests flake8

     docker-compose run --rm django flake8
    

Django Internationalization

  1. Execute this command to runs over the entire source tree of the current directory and pulls out all strings marked for translation.

     docker-compose run --rm django python manage.py makemessages --no-location -l es
    
  2. Edit file public/locale/es/LC_MESSAGES/django.po and add a translation.

     msgid "Hello world"
     msgstr "Hola mundo"
    
  3. Compiles .po files to .mo files for use with builtin gettext support.

     docker-compose run --rm django python manage.py compilemessages
    

Run the project for Production

  1. Build

     docker-compose -f docker-compose-production.yml build
    
  2. Initialize

     docker-compose -f docker-compose-production.yml up -d mysql
     docker-compose -f docker-compose-production.yml run --rm django python manage.py migrate --noinput
     docker-compose -f docker-compose-production.yml run --rm django python manage.py collectstatic --noinput
     docker-compose -f docker-compose-production.yml run --rm django python manage.py compilemessages
    
  3. Run Django server

     docker-compose -f docker-compose-production.yml up -d
    
  4. Visit API api.labcomp.edwarbaron.me/

Automatic deploy using fabric

  1. On Linux

     pip install fabric
     ~/.local/bin/fab deploy_dev
    
  2. On macOS

     pip install --user fabric
     ~/Library/Python/2.7/bin/fab deploy_dev
    
  3. Other taks

    1. fab deploy_dev
    2. fab deploy_production
    3. fab test
    4. fab update_local_db