GeoNode template project. Generates a django project with GeoNode support.
requirements.txt
python3.10 -m venv ~/.venvs/project_name
source ~/.venvs/{{ project_name }}/bin/activate
pip install Django==4.2.9
mkdir ~/project_name
GN_VERSION=master # Define the branch or tag you want to generate the project from
django-admin startproject --template=https://github.com/GeoNode/geonode-project/archive/refs/heads/$GN_VERSION.zip -e py,sh,md,rst,json,yml,ini,env,sample,properties -n monitoring-cron -n Dockerfile project_name ~/project_name
cd ~/project_name
python create-envfile.py
create-envfile.py
accepts the following arguments:
--https
: Enable SSL. It's disabled by default--env_type
:
prod
DEBUG
is disabled and the creation of a valid SSL
is requested to Letsencrypt's ACME servertest
DEBUG
is disabled and a test SSL
certificate is generated for local testingdev
DEBUG
is enabled and no SSL
certificate is generated--hostname
: The URL that whill serve GeoNode (localhost
by default)--email
: The administrator's email. Notice that a real email and a valid SMPT configurations are required if --env_type
is seto to prod
. Letsencrypt uses to email for issuing the SSL certificate --geonodepwd
: GeoNode's administrator password. A random value is set if left empty--geoserverpwd
: GeoNode's administrator password. A random value is set if left empty--pgpwd
: PostgreSQL's administrator password. A random value is set if left empty--dbpwd
: GeoNode DB user role's password. A random value is set if left empty--geodbpwd
: GeoNode data DB user role's password. A random value is set if left empty--clientid
: Client id of Geoserver's GeoNode Oauth2 client. A random value is set if left empty--clientsecret
: Client secret of Geoserver's GeoNode Oauth2 client. A random value is set if left empty
docker compose build
docker compose up -d
Available at
http://geonode.org/dev-workshop
NOTE: You can call your geonode project whatever you like except 'geonode'. Follow 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.
To setup your project follow these instructions:
Generate the project
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==3.2.16
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 }}
Create the .env file
An .env
file is requird to run the application. It can be created from the .env.sample
either manually or with the create-envfile.py script.
The script accepts several parameters to create the file, in detail:
prod
, test
or dev
. It will set the DEBUG
variable to False
(prod
, test
) or True
(dev
)file: absolute path to a json file that contains all the above configuration
NOTE:
If some value is not provided, a random string is used
Example USAGE
python create-envfile.py -f /opt/core/geonode-project/file.json \
--hostname localhost \
--https \
--email random@email.com \
--geonodepwd gn_password \
--geoserverpwd gs_password \
--pgpwd pg_password \
--dbpwd db_password \
--geodbpwd _db_password \
--clientid 12345 \
--clientsecret abc123
Example JSON expected:
{
"hostname": "value",
"https": "value",
"email": "value",
"geonodepwd": "value",
"geoserverpwd": "value",
"pgpwd": "value",
"dbpwd": "value",
"geodbpwd": "value",
"clientid": "value",
"clientsecret": "value"
}
Skip this part if you want to run the project using Docker instead see Start your server using Docker
Setup the Python Dependencies
NOTE: Important: modify your requirements.txt
file, by adding the GeoNode
branch before continue!
(see Hints: Configuring requirements.txt
)
cd src
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
source ../.override_dev_env
# Using the Default Settings
sh ./paver_dev.sh reset
sh ./paver_dev.sh setup
sh ./paver_dev.sh sync
sh ./paver_dev.sh start
Access GeoNode from browser
NOTE: default admin user is admin
(with pw: admin
)
http://localhost:8000/
You need Docker 1.12 or higher, get the latest stable official release for your platform. Once you have the project configured run the following command from the root folder of the project.
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
Access the site on http://localhost/
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
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
docker-compose up --build -d
docker-compose stop
WARNING: This will wipe out all the repositories created until now.
NOTE: The images must be stopped first
docker system prune -a
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'
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'
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.
requirements.txt
You may want to configure your requirements.txt, if you are using additional or custom versions of python packages. For example
Django==3.2.16
git+git://github.com/<your organization>/geonode.git@<your branch>
In case you need to increase the PostgreSQL Max Connections , you can modify the POSTGRESQL_MAX_CONNECTIONS variable in .env file as below:
POSTGRESQL_MAX_CONNECTIONS=200
In this case PostgreSQL will run accepting 200 maximum connections.
Testing with vagrant works like this: What vagrant does:
Starts a vm for test on docker swarm:
vagrant plugin install vagrant-reload
#test things for docker-compose
vagrant up
# check services are up upon reboot
vagrant ssh geonode-compose -c 'docker ps'
Test geonode on http://localhost:8888/
To clean up things and delete the vagrant box:
vagrant destroy -f
What vagrant does:
Starts a vm for test on docker swarm:
To test on a docker swarm enable vagrant box:
vagrant up
VAGRANT_VAGRANTFILE=Vagrantfile.stack vagrant up
# check services are up upon reboot
VAGRANT_VAGRANTFILE=Vagrantfile.stack vagrant ssh geonode-compose -c 'docker service ls'
Test geonode on http://localhost:8888/ Again, to clean up things and delete the vagrant box:
VAGRANT_VAGRANTFILE=Vagrantfile.stack vagrant destroy -f
for direct deveolpment on geonode-project after first vagrant up
to rebuild after changes to project, you can do vagrant reload
like this:
vagrant up
What vagrant does (swarm or comnpose cases):
Starts a vm for test on plain docker service with docker-compose:
[1] to achieve docker-compose build --no-cache
just destroy vagrant boxes vagrant destroy -f