GeoNode template project. Generates a django project with GeoNode support.
This repository contains a Django application based on Geonode project that provide metadata and geospatial data from the Metropolitan Study Center (CEM) of São Paulo.
This information is shared with everybody.
The demo version it is at the CEM website of Interactive Systems, and you can see here
This section covers the necessary steps to get the application running on a local development machine. It assumes you're using Ubuntu, so you may need to adapt some of the commands if this is not true.
- Docker
- Docker-compose
sudo add-apt-repository universe
sudo apt-get update -y
sudo apt-get install -y git-core git-buildpackage debhelper devscripts
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose
sudo apt autoremove --purge
sudo adduser geonode
sudo usermod -aG sudo geonode
sudo usermod -aG docker geonode
su geonodePrepare the environment
sudo mkdir -p /opt/geonode_custom/
sudo usermod -a -G www-data geonode
sudo chown -Rf geonode:www-data /opt/geonode_custom/
sudo chmod -Rf 775 /opt/geonode_custom/Clone the source code
cd /opt/geonode_custom/
git clone https://github.com/GeoNode/geonode-project.git -b 3.1.xMake an instance out of the Django Template Note: We will call our instance geocem. You can change the name at your convenience.
Install virtualenv and virtualenvwrapper, edit .bashrc file:
#Virtualenvwrapper settings:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/geonode/.local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.shmkvirtualenv --python=/usr/bin/python3 geocem
Alterantively you can also create the virtual env like below
python3 -m venv /home/geonode/dev/.venvs/geocem
source /home/geonode/dev/.venvs/geocem/bin/activate
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 geocem
cd /opt/geonode_custom/geocemModify the code and the templates and rebuild the Docker Containers
docker-compose -f docker-compose.yml build --no-cacheFinally, run the containers
docker-compose -f docker-compose.yml up -dStep 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"
git branch -M main
git remote add origin https://github.com/repo_demo/demo.git
git push -u origin mainStep 3. Set up a free account on github or bitbucket and make a copy of the repo there.
Update the templates or the Django models. Once in the bash you can edit the templates or the Django models/classes. From here you can run any standard Django management command.
docker exec -it django4geocem /bin/bashWhenever you change a template/CSS/Javascript remember to run later:
python manage.py collectstaticin order to update the files into the statics Docker volume.
Warning: This is an external volume, and a simple restart won’t update it. You have to be careful and keep it aligned with your changes.
Whenever you need to change some settings or environment variable, the easiest thing to do is to:
# Stop the container
docker-compose stop
# Restart the container in Daemon mode
docker-compose -f docker-compose.yml up -dWhenever you change the model, remember to run later in the container via bash:
python manage.py makemigrations
python manage.py migrateSOURCE_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'Copy files from container:
sudo docker cp django4geo_cem:"/backup_restore" "/opt/"Copy files to container:
sudo docker cp "/backup_folder/*" django4geo_cem:"/backup_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'- First, get into the bash Geoserver container:
docker exec -it geoserver4geocem /bin/bash- Second, get into the path of Tomcat, then uncomment the following and from webapps/geoserver/WEB-INF/web.xml:
<filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>*</param-value>
</init-param>
</filter>and regardless of application server choice uncomment:
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> - Finally restart the geoserver Reference
During the implementation of the project will be constantly updated the following features:
- Design the website (style)
- Data Migration
- User and development documentation
- Define the style of the layers maps
- ** Goals: ** lay the groundwork for the next phases. The goal of this phase was mainly to familiarize with the tools that was chosen to adopt in the project, and test drive each one.
- see all issues that were planned (and delivered) for this phase here.
- ** Goals: **
- Design the basic style for the website.
- Migrate the available data.
- Configure users accounts
- see all issues that were planned (and delivered) for this phase here.
- ** Goals: **
- Link and fill the information from GeoCEM to he Dataverse
- Add feature module for fast migration data
- Configure the advance search
- see all issues that were planned (and delivered) for this phase here.
- ** Goals: ** Publish the project
- see all issues that were planned (and delivered) for this phase here.