/cartoview-project

A django template project for creating custom Cartoview projects.

Primary LanguagePython

{{ project_name|title }}

GeoNode template project. Generates a django project with GeoNode support.

Table of Contents

Developer Workshop

Available at

  http://geonode.org/dev-workshop

Create a custom project

NOTE: You can call your geonode project whatever you like following the naming conventions for python packages (generally lower case with underscores (_). In the examples below, replace {{ project_name }} with whatever you would like to name your project.

Using a Python virtual environment

NOTE: Skip this part if you want to run the project using Docker instead

(see Start your server using Docker)

To setup your project using a local python virtual environment, follow these instructions:

  1. Prepare the Environment

    git clone https://github.com/GeoNode/geonode-project.git -b <your_branch>
    source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
    mkvirtualenv --python=/usr/bin/python3 {{ project_name }}
    pip install Django==2.2.12
    
    django-admin startproject --template=./geonode-project -e py,sh,md,rst,json,yml,ini,env,sample,properties -n monitoring-cron -n Dockerfile {{ project_name }}
    
    cd {{ project_name }}
  2. Setup the Python Dependencies

    NOTE: Important: modify your requirements.txt file, by adding the GeoNode branch before continue!

    (see Hints: Configuring requirements.txt)

    pip install -r requirements.txt --upgrade
    pip install -e . --upgrade
    
    # Install GDAL Utilities for Python
    pip install pygdal=="`gdal-config --version`.*"
    
    # Dev scripts
    mv .override_dev_env.sample .override_dev_env
    mv manage_dev.sh.sample manage_dev.sh
    mv paver_dev.sh.sample paver_dev.sh
    
    # Using the Default Settings
    ./paver_dev.sh reset
    ./paver_dev.sh setup
    ./paver_dev.sh sync
    ./paver_dev.sh start
  3. Access GeoNode from browser

    NOTE: default admin user is admin (with pw: admin)

    http://localhost:8000/

Start your server using Docker

You need Docker 1.12 or higher, get the latest stable official release for your platform.

  1. Prepare the Environment

    git clone https://github.com/GeoNode/geonode-project.git -b <your_branch>
    source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
    mkvirtualenv --python=/usr/bin/python3 {{ project_name }}
    pip install Django==2.2.15
    
    django-admin startproject --template=./geonode-project -e py,sh,md,rst,json,yml,ini,env,sample,properties -n monitoring-cron -n Dockerfile {{ project_name }}
    
    cd {{ project_name }}
  2. Run docker-compose to start it up (get a cup of coffee or tea while you wait)

    docker-compose build --no-cache
    docker-compose up -d
    set COMPOSE_CONVERT_WINDOWS_PATHS=1

    before running docker-compose up

  3. Access the site on http://localhost/

Run the instance in development mode

Use dedicated docker-compose files while developing

NOTE: In this example we are going to keep localhost as the target IP for GeoNode

docker-compose -f docker-compose.development.yml -f docker-compose.development.override.yml up

Run the instance on a public site

Preparation of the image (First time only)

NOTE: In this example we are going to publish to the public IP http://123.456.789.111

vim .env
  --> replace localhost with 123.456.789.111 everywhere

Startup the image

docker-compose up --build -d

Stop the Docker Images

docker-compose stop

Fully Wipe-out the Docker Images

WARNING: This will wipe out all the repositories created until now.

NOTE: The images must be stopped first

docker system prune -a

Backup and Restore from Docker Images

Run a Backup

SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/backup.sh $BKP_FOLDER_NAME
  • BKP_FOLDER_NAME: Default value = backup_restore Shared Backup Folder name. The scripts assume it is located on "root" e.g.: /$BKP_FOLDER_NAME/

  • SOURCE_URL: Source Server URL, the one generating the "backup" file.

  • TARGET_URL: Target Server URL, the one which must be synched.

e.g.:

docker exec -it django4{{project_name}} sh -c 'SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/backup.sh $BKP_FOLDER_NAME'

Run a Restore

SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/restore.sh $BKP_FOLDER_NAME
  • BKP_FOLDER_NAME: Default value = backup_restore Shared Backup Folder name. The scripts assume it is located on "root" e.g.: /$BKP_FOLDER_NAME/

  • SOURCE_URL: Source Server URL, the one generating the "backup" file.

  • TARGET_URL: Target Server URL, the one which must be synched.

e.g.:

docker exec -it django4{{project_name}} sh -c 'SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/restore.sh $BKP_FOLDER_NAME'

Recommended: Track your changes

Step 1. Install Git (for Linux, Mac or Windows).

Step 2. Init git locally and do the first commit:

git init
git add *
git commit -m "Initial Commit"

Step 3. Set up a free account on github or bitbucket and make a copy of the repo there.

Hints: Configuring requirements.txt

You may want to configure your requirements.txt, if you are using additional or custom versions of python packages. For example

Django==2.2.12
git+git://github.com/<your organization>/geonode.git@<your branch>