Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
languages: ${{ matrix.language }}

paths-ignore:
- src/project_name/__init__.py
- src/project/__init__.py
22 changes: 9 additions & 13 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPOSE_PROJECT_NAME={{project_name}}
COMPOSE_PROJECT_NAME=geonode_project
DOCKER_ENV=production
BACKUPS_VOLUME_DRIVER=local

Expand All @@ -16,26 +16,26 @@ INVOKE_LOG_STDOUT=true
# LANGUAGE_CODE=it-it
# LANGUAGES=(('en-us','English'),('it-it','Italiano'))

DJANGO_SETTINGS_MODULE={{project_name}}.settings
DJANGO_SETTINGS_MODULE=geonode_project.settings
GEONODE_INSTANCE_NAME=geonode

# #################
# backend
# #################
POSTGRES_USER=postgres
POSTGRES_PASSWORD={pgpwd}
GEONODE_DATABASE={{project_name}}
GEONODE_DATABASE_USER={{project_name}}
GEONODE_DATABASE=project
GEONODE_DATABASE_USER=project
GEONODE_DATABASE_PASSWORD={dbpwd}
GEONODE_GEODATABASE={{project_name}}_data
GEONODE_GEODATABASE_USER={{project_name}}_data
GEONODE_GEODATABASE=project_data
GEONODE_GEODATABASE_USER=project_data
GEONODE_GEODATABASE_PASSWORD={geodbpwd}
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
DATABASE_HOST=db
DATABASE_PORT=5432
DATABASE_URL=postgis://{{project_name}}:{dbpwd}@db:5432/{{project_name}}
GEODATABASE_URL=postgis://{{project_name}}_data:{geodbpwd}@db:5432/{{project_name}}_data
DATABASE_URL=postgis://project:{dbpwd}@db:5432/project
GEODATABASE_URL=postgis://project_data:{geodbpwd}@db:5432/project_data
GEONODE_DB_CONN_MAX_AGE=0
GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
Expand Down Expand Up @@ -104,7 +104,7 @@ OGC_REQUEST_POOL_CONNECTIONS=10
# Java Options & Memory
ENABLE_JSONP=true
outFormat=text/javascript
GEOSERVER_JAVA_OPTS=-Djava.awt.headless=true -Xms4G -Xmx4G -Dgwc.context.suffix=gwc -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/var/log/jvm.log -XX:PerfDataSamplingInterval=500 -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UseGCOverheadLimit -XX:ParallelGCThreads=4 -Dfile.encoding=UTF8 -Djavax.servlet.request.encoding=UTF-8 -Djavax.servlet.response.encoding=UTF-8 -Duser.timezone=GMT -Dorg.geotools.shapefile.datetime=false -DGS-SHAPEFILE-CHARSET=UTF-8 -DGEOSERVER_CSRF_DISABLED=true -DPRINT_BASE_URL={siteurl}/geoserver/pdf -DALLOW_ENV_PARAMETRIZATION=true -Xbootclasspath/a:/usr/local/tomcat/webapps/geoserver/WEB-INF/lib/marlin-0.9.3-Unsafe.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine
GEOSERVER_JAVA_OPTS="-Djava.awt.headless=true -Xms4G -Xmx4G -Dgwc.context.suffix=gwc -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/var/log/jvm.log -XX:PerfDataSamplingInterval=500 -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UseGCOverheadLimit -XX:ParallelGCThreads=4 -Dfile.encoding=UTF8 -Djavax.servlet.request.encoding=UTF-8 -Djavax.servlet.response.encoding=UTF-8 -Duser.timezone=GMT -Dorg.geotools.shapefile.datetime=false -DGS-SHAPEFILE-CHARSET=UTF-8 -DGEOSERVER_CSRF_DISABLED=true -DPRINT_BASE_URL={siteurl}/geoserver/pdf -DALLOW_ENV_PARAMETRIZATION=true -Xbootclasspath/a:/usr/local/tomcat/webapps/geoserver/WEB-INF/lib/marlin-0.9.3-Unsafe.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine"

# #################
# Security
Expand Down Expand Up @@ -163,10 +163,6 @@ OAUTH2_CLIENT_SECRET={clientsecret}
API_LOCKDOWN=False
TASTYPIE_APIKEY=

# #################
# Production and
# Monitoring
# #################
DEBUG={debug}

SECRET_KEY='{secret_key}'
Expand Down
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
max-line-length = 200
exclude =
geonode/*/migrations/*
scripts
docs
static
migrations
node_modules
extend-ignore = E122,E124,E203,E731,F403,F405
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL"

on:
push:
branches: [ "master", 4.1.x ]
branches: [ "master", 5.0.x ]
pull_request:
branches: [ "master", 4.1.x ]
branches: [ "master", 5.0.x ]
schedule:
- cron: '38 4 * * 5'

Expand Down
27 changes: 16 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
FROM geonode/geonode-base:latest-ubuntu-24.04
LABEL GeoNode development team

RUN mkdir -p /usr/src/{{project_name}}
RUN mkdir -p /usr/src/project

RUN apt-get update -y && apt-get install curl wget unzip gnupg2 locales -y

RUN sed -i -e 's/# C.UTF-8 UTF-8/C.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

WORKDIR /usr/src/project

COPY src /usr/src/{{project_name}}/
WORKDIR /usr/src/{{project_name}}
COPY src/tasks.py \
src/entrypoint.sh \
src/requirements.txt \
/usr/src/project/

COPY src/wait-for-databases.sh /usr/bin/wait-for-databases
RUN chmod +x /usr/bin/wait-for-databases
RUN chmod +x /usr/src/{{project_name}}/tasks.py \
&& chmod +x /usr/src/{{project_name}}/entrypoint.sh
RUN chmod +x /usr/src/project/tasks.py \
&& chmod +x /usr/src/project/entrypoint.sh

COPY src/celery.sh /usr/bin/celery-commands
RUN chmod +x /usr/bin/celery-commands

COPY src/celery-cmd /usr/bin/celery-cmd
RUN chmod +x /usr/bin/celery-cmd

RUN yes w | pip install --src /usr/src -r requirements.txt &&\
yes w | pip install -e .
RUN python -m pip install -U pip setuptools wheel
RUN yes w | pip install --src /usr/src -r requirements.txt

RUN apt-get autoremove --purge &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*

COPY src/ /usr/src/project/
RUN yes w | pip install -e .

EXPOSE 8000
90 changes: 7 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# {{ project_name|title }}
# GeoNode Project

GeoNode template project. Generates a django project with GeoNode support.
GeoNode Django project. This can be forked to customize, add Python modules or Django apps to your GeoNode instance.

## Table of Contents

- [Quick Docker Start](#quick-docker-start)
- [Developer Workshop](#developer-workshop)
- [Create a custom project](#create-a-custom-project)
- [Start your server using Docker](#start-your-server-using-docker)
- [Run the instance in development mode](#run-the-instance-in-development-mode)
- [Run the instance on a public site](#run-the-instance-on-a-public-site)
Expand All @@ -16,77 +14,13 @@ GeoNode template project. Generates a django project with GeoNode support.
- [Hints: Configuring `requirements.txt`](#hints-configuring-requirementstxt)

## Quick Docker Start

```bash
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
```

The project can also be generated from a local checkout of the goenode-project repository

```bash
git clone https://github.com/GeoNode/geonode-project
git checkout $GN_VERSION
django-admin startproject --template=./geonode-project -e py,sh,md,rst,json,yml,ini,env,sample,properties -n monitoring-cron -n Dockerfile project_name ~/project_name

```

`create-envfile.py` accepts the following arguments:

- `--https`: Enable SSL. It's disabled by default
- `--env_type`:
- When set to `prod` `DEBUG` is disabled and the creation of a valid `SSL` is requested to Letsencrypt's ACME server
- When set to `test` `DEBUG` is disabled and a test `SSL` certificate is generated for local testing
- When set to `dev` `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
```bash
docker compose build
docker compose up -d
```

## Developer Workshop

Available at

```bash
http://geonode.org/dev-workshop
```

## Create a custom project

**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:

1. Generate the project

```bash
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 }}
cd project
```

2. Create the .env file
Expand Down Expand Up @@ -167,16 +101,6 @@ Once you have the project configured run the following command from the root fol

2. 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

```bash
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)
Expand Down Expand Up @@ -215,7 +139,7 @@ docker system prune -a
### Run a Backup

```bash
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/br/backup.sh $BKP_FOLDER_NAME
```

- BKP_FOLDER_NAME:
Expand All @@ -232,13 +156,13 @@ SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/backup.sh $B
e.g.:

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

### Run a Restore

```bash
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/restore.sh $BKP_FOLDER_NAME
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./project/br/restore.sh $BKP_FOLDER_NAME
```

- BKP_FOLDER_NAME:
Expand All @@ -255,7 +179,7 @@ SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/restore.sh $
e.g.:

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

## Recommended: Track your changes
Expand Down
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.9'

# Common Django template for GeoNode and Celery services below
x-common-django:
&default-common-django
Expand All @@ -8,7 +6,7 @@ x-common-django:
env_file:
- .env
volumes:
# - './src:/usr/src/{{project_name}}'
# - './src:/usr/src/project' # Uncomment for local development
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
- backup-restore:/backup_restore
Expand All @@ -35,8 +33,8 @@ services:
retries: 2
environment:
- IS_CELERY=False
entrypoint: ["/usr/src/{{project_name}}/entrypoint.sh"]
command: "uwsgi --ini /usr/src/{{project_name}}/uwsgi.ini"
entrypoint: ["/usr/src/project/entrypoint.sh"]
command: "uwsgi --ini /usr/src/project/uwsgi.ini"

# Celery worker that executes celery tasks created by Django.
celery:
Expand All @@ -47,7 +45,7 @@ services:
condition: service_healthy
environment:
- IS_CELERY=True
entrypoint: ["/usr/src/{{project_name}}/entrypoint.sh"]
entrypoint: ["/usr/src/project/entrypoint.sh"]
command: "celery-cmd"

# Nginx is serving django static and media files and proxies to django and geonode
Expand Down
7 changes: 1 addition & 6 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ invoke () {
then
/usr/local/bin/invoke $@
else
/usr/local/bin/invoke $@ > /usr/src/{{project_name}}/invoke.log 2>&1
/usr/local/bin/invoke $@ > /usr/src/project/invoke.log 2>&1
fi
echo "$@ tasks done"
}
Expand All @@ -35,10 +35,6 @@ echo GEODATABASE_URL=$GEODATABASE_URL
echo SITEURL=$SITEURL
echo ALLOWED_HOSTS=$ALLOWED_HOSTS
echo GEOSERVER_PUBLIC_LOCATION=$GEOSERVER_PUBLIC_LOCATION
echo MONITORING_ENABLED=$MONITORING_ENABLED
echo MONITORING_HOST_NAME=$MONITORING_HOST_NAME
echo MONITORING_SERVICE_NAME=$MONITORING_SERVICE_NAME
echo MONITORING_DATA_TTL=$MONITORING_DATA_TTL

# invoke waitfordbs

Expand All @@ -54,7 +50,6 @@ else

if [ ${FORCE_REINIT} = "true" ] || [ ${FORCE_REINIT} = "True" ] || [ ! -e "/mnt/volumes/statics/geonode_init.lock" ]; then
invoke fixtures
invoke monitoringfixture
invoke initialized
invoke updateadmin
fi
Expand Down
13 changes: 1 addition & 12 deletions src/project_name/__init__.py → src/geonode_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,4 @@
#
#########################################################################

import os

__version__ = (4, 2, 0, "dev", 0)


default_app_config = "{{ project_name }}.apps.AppConfig"


def get_version():
import {{ project_name }}.version

return {{ project_name }}.version.get_version(__version__)
default_app_config = "geonode_project.apps.AppConfig"
4 changes: 2 additions & 2 deletions src/project_name/apps.py → src/geonode_project/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def run_setup_hooks(*args, **kwargs):


class AppConfig(BaseAppConfig):
name = "{{ project_name }}"
label = "{{ project_name }}"
name = "geonode_project"
label = "geonode_project"

def ready(self):
super(AppConfig, self).ready()
Expand Down
Loading
Loading