Skip to content

gsi-luis/djangolearning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

## Django Learning

### Installation for development using Docker and Docker-compose

#### Install Docker:

1. Install dependencies

    ````
    sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    ````

2. Add Docker’s GPG Key

    ````
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
    ````

3. Install the Docker Repository

    ````
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs)  stable"
    ````

4. Update Repositories

    ````
    sudo apt-get update
    ````

5. Install Latest Version of Docker

    ````
    sudo apt-get install docker-ce
    ````

#### Install Docker-compose

1. Download the Docker Compose binary

    ````
    sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    ````

2. Apply executable permissions to the Compose binary

    ````
    sudo chmod +x /usr/local/bin/docker-compose
    ````


#### Clone repository

````
git clone https://github.com/gsi-luis/djangolearning.git
````

#### Structure of project

````
/path/to/root/of/project
    |-config          (configurations files used into containers)
    |-Dockerfiles     (docker files and docker composes)
    |-src             (root of project django)
    |-.env.example    (env file example by keys used by environment)
    |-deploy-dev      (bash file commands for deployment environment develop)
    |-LICENSE
    |-README.md
````


#### Languages and frameworks of project
````
* Python 3.8.3
* Django 3.0.8
* Postgis 9.6+
* Nginx

Note: view requirements.txt for all dependencies used.
````

#### Set config values on .env.dev file with configurations for environment

````
cd /path/to/root/of/project
cp .env.example src/.env
nano src/.env
````

#### Generate certificates file for elastic search nodes

````
Execute commands:
1. docker exec -it django.learning.es01.dev.local.com sh

2. ./bin/elasticsearch-certutil ca --ca-dn CN=django.learning.es01.dev.local.com

3. ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 -name "CN=django.learning.es01.dev.local.com,OU=Elastic Search,DC=django.learning.es01.dev.local.com,DC=com"
````

#### Generate certificates file for connection into elastic search and kibana

````
Execute commands:
1. openssl pkcs12 -in elastic-stack-certificates. -out elastic-stack-certificates.key.pem -nocerts -nodes

2. openssl pkcs12 -in elastic-stack-certificates.p12 -out elastic-stack-certificates.key.pem -nocerts -nodes
````

#### Edit your host configuration file to add the app domains

172.60.0.2  django.learning.app.dev.local.com
172.60.0.3  django.learning.web.dev.local.com
172.70.0.3  django.learning.postgres.dev.local.com

#### Start the application

1. Move to root of project and run script to initiate application

    ````
    cd /path/to/root/of/project
    bash deploy-dev
    ````
2. Create admin user for default:
    ````
    docker exec -it django.learning.app.dev.local.com sh
    django-admin createsuperuser
    ````

3. Access to app from browser:
    ````
   http://django.learning.web.dev.local.com/admin/
   ````
#### Run Unit tests

Run from project root directory inside of django.learning.app.dev.local.com container:

````
python manage.py test
````

### General ENV variables
````
DEBUG=1
SECRET_KEY='bwj+--xg41((^+rqcvi!ueabmd6bbgl_vqs@5fho05ygdj!tx='
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 172.60.0.2 django.learning.web.dev.local.com django.learning.app.dev.local.com [::1]
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=dev
SQL_USER=djangolearninglocal
SQL_PASSWORD=djangolearninglocal
SQL_HOST=python_learning_postgres
SQL_PORT=5432
````

About

Django Learning

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published