Skip to content

Commit 3bbf8b6

Browse files
authored
[Fixes #599] Refactor project to be forked (#600)
* Refactor project to be forked directly * Change order of edtiable packages * renamed module to geonode_project * Removed version module * Migrated to pyproject * Fixed formatting * Removed monitoring legacy code * Updated CodeQL workflow branches * Rename the container project to project, to clarify it's not geonode itself
1 parent e7e80bb commit 3bbf8b6

36 files changed

Lines changed: 122 additions & 447 deletions

.codeql/codeql-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
languages: ${{ matrix.language }}
22

33
paths-ignore:
4-
- src/project_name/__init__.py
4+
- src/project/__init__.py

.env.sample

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
COMPOSE_PROJECT_NAME={{project_name}}
1+
COMPOSE_PROJECT_NAME=geonode_project
22
DOCKER_ENV=production
33
BACKUPS_VOLUME_DRIVER=local
44

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

19-
DJANGO_SETTINGS_MODULE={{project_name}}.settings
19+
DJANGO_SETTINGS_MODULE=geonode_project.settings
2020
GEONODE_INSTANCE_NAME=geonode
2121

2222
# #################
2323
# backend
2424
# #################
2525
POSTGRES_USER=postgres
2626
POSTGRES_PASSWORD={pgpwd}
27-
GEONODE_DATABASE={{project_name}}
28-
GEONODE_DATABASE_USER={{project_name}}
27+
GEONODE_DATABASE=project
28+
GEONODE_DATABASE_USER=project
2929
GEONODE_DATABASE_PASSWORD={dbpwd}
30-
GEONODE_GEODATABASE={{project_name}}_data
31-
GEONODE_GEODATABASE_USER={{project_name}}_data
30+
GEONODE_GEODATABASE=project_data
31+
GEONODE_GEODATABASE_USER=project_data
3232
GEONODE_GEODATABASE_PASSWORD={geodbpwd}
3333
GEONODE_DATABASE_SCHEMA=public
3434
GEONODE_GEODATABASE_SCHEMA=public
3535
DATABASE_HOST=db
3636
DATABASE_PORT=5432
37-
DATABASE_URL=postgis://{{project_name}}:{dbpwd}@db:5432/{{project_name}}
38-
GEODATABASE_URL=postgis://{{project_name}}_data:{geodbpwd}@db:5432/{{project_name}}_data
37+
DATABASE_URL=postgis://project:{dbpwd}@db:5432/project
38+
GEODATABASE_URL=postgis://project_data:{geodbpwd}@db:5432/project_data
3939
GEONODE_DB_CONN_MAX_AGE=0
4040
GEONODE_DB_CONN_TOUT=5
4141
DEFAULT_BACKEND_DATASTORE=datastore
@@ -104,7 +104,7 @@ OGC_REQUEST_POOL_CONNECTIONS=10
104104
# Java Options & Memory
105105
ENABLE_JSONP=true
106106
outFormat=text/javascript
107-
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
107+
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"
108108

109109
# #################
110110
# Security
@@ -163,10 +163,6 @@ OAUTH2_CLIENT_SECRET={clientsecret}
163163
API_LOCKDOWN=False
164164
TASTYPIE_APIKEY=
165165

166-
# #################
167-
# Production and
168-
# Monitoring
169-
# #################
170166
DEBUG={debug}
171167

172168
SECRET_KEY='{secret_key}'

.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
max-line-length = 200
3+
exclude =
4+
geonode/*/migrations/*
5+
scripts
6+
docs
7+
static
8+
migrations
9+
node_modules
10+
extend-ignore = E122,E124,E203,E731,F403,F405

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [ "master", 4.1.x ]
5+
branches: [ "master", 5.0.x ]
66
pull_request:
7-
branches: [ "master", 4.1.x ]
7+
branches: [ "master", 5.0.x ]
88
schedule:
99
- cron: '38 4 * * 5'
1010

Dockerfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
FROM geonode/geonode-base:latest-ubuntu-24.04
2-
LABEL GeoNode development team
3-
4-
RUN mkdir -p /usr/src/{{project_name}}
2+
RUN mkdir -p /usr/src/project
53

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

86
RUN sed -i -e 's/# C.UTF-8 UTF-8/C.UTF-8 UTF-8/' /etc/locale.gen && \
97
locale-gen
10-
ENV LC_ALL C.UTF-8
11-
ENV LANG C.UTF-8
8+
ENV LC_ALL=C.UTF-8
9+
ENV LANG=C.UTF-8
10+
11+
WORKDIR /usr/src/project
1212

13-
COPY src /usr/src/{{project_name}}/
14-
WORKDIR /usr/src/{{project_name}}
13+
COPY src/tasks.py \
14+
src/entrypoint.sh \
15+
src/requirements.txt \
16+
/usr/src/project/
1517

1618
COPY src/wait-for-databases.sh /usr/bin/wait-for-databases
1719
RUN chmod +x /usr/bin/wait-for-databases
18-
RUN chmod +x /usr/src/{{project_name}}/tasks.py \
19-
&& chmod +x /usr/src/{{project_name}}/entrypoint.sh
20+
RUN chmod +x /usr/src/project/tasks.py \
21+
&& chmod +x /usr/src/project/entrypoint.sh
2022

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

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

27-
RUN yes w | pip install --src /usr/src -r requirements.txt &&\
28-
yes w | pip install -e .
29+
RUN python -m pip install -U pip setuptools wheel
30+
RUN yes w | pip install --src /usr/src -r requirements.txt
2931

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

36+
COPY src/ /usr/src/project/
37+
RUN yes w | pip install -e .
38+
3439
EXPOSE 8000

README.md

Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# {{ project_name|title }}
1+
# GeoNode Project
22

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

55
## Table of Contents
66

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

1816
## Quick Docker Start
19-
20-
```bash
21-
python3.10 -m venv ~/.venvs/project_name
22-
source ~/.venvs/{{ project_name }}/bin/activate
23-
24-
pip install Django==4.2.9
25-
26-
mkdir ~/project_name
27-
28-
GN_VERSION=master # Define the branch or tag you want to generate the project from
29-
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
30-
31-
cd ~/project_name
32-
python create-envfile.py
33-
```
34-
35-
The project can also be generated from a local checkout of the goenode-project repository
36-
37-
```bash
38-
git clone https://github.com/GeoNode/geonode-project
39-
git checkout $GN_VERSION
40-
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
41-
42-
```
43-
44-
`create-envfile.py` accepts the following arguments:
45-
46-
- `--https`: Enable SSL. It's disabled by default
47-
- `--env_type`:
48-
- When set to `prod` `DEBUG` is disabled and the creation of a valid `SSL` is requested to Letsencrypt's ACME server
49-
- When set to `test` `DEBUG` is disabled and a test `SSL` certificate is generated for local testing
50-
- When set to `dev` `DEBUG` is enabled and no `SSL` certificate is generated
51-
- `--hostname`: The URL that whill serve GeoNode (`localhost` by default)
52-
- `--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
53-
- `--geonodepwd`: GeoNode's administrator password. A random value is set if left empty
54-
- `--geoserverpwd`: GeoNode's administrator password. A random value is set if left empty
55-
- `--pgpwd`: PostgreSQL's administrator password. A random value is set if left empty
56-
- `--dbpwd`: GeoNode DB user role's password. A random value is set if left empty
57-
- `--geodbpwd`: GeoNode data DB user role's password. A random value is set if left empty
58-
- `--clientid`: Client id of Geoserver's GeoNode Oauth2 client. A random value is set if left empty
59-
- `--clientsecret`: Client secret of Geoserver's GeoNode Oauth2 client. A random value is set if left empty
60-
```bash
61-
docker compose build
62-
docker compose up -d
63-
```
64-
65-
## Developer Workshop
66-
67-
Available at
68-
69-
```bash
70-
http://geonode.org/dev-workshop
71-
```
72-
73-
## Create a custom project
74-
75-
**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.*
76-
7717
To setup your project follow these instructions:
7818

7919
1. Generate the project
8020

8121
```bash
8222
git clone https://github.com/GeoNode/geonode-project.git -b <your_branch>
83-
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
84-
mkvirtualenv --python=/usr/bin/python3 {{ project_name }}
85-
pip install Django==3.2.16
86-
87-
django-admin startproject --template=./geonode-project -e py,sh,md,rst,json,yml,ini,env,sample,properties -n monitoring-cron -n Dockerfile {{ project_name }}
88-
89-
cd {{ project_name }}
23+
cd project
9024
```
9125

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

168102
2. Access the site on http://localhost/
169103

170-
## Run the instance in development mode
171-
172-
### Use dedicated docker-compose files while developing
173-
174-
**NOTE**: In this example we are going to keep localhost as the target IP for GeoNode
175-
176-
```bash
177-
docker-compose -f docker-compose.development.yml -f docker-compose.development.override.yml up
178-
```
179-
180104
## Run the instance on a public site
181105

182106
### Preparation of the image (First time only)
@@ -215,7 +139,7 @@ docker system prune -a
215139
### Run a Backup
216140

217141
```bash
218-
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/backup.sh $BKP_FOLDER_NAME
142+
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./project/br/backup.sh $BKP_FOLDER_NAME
219143
```
220144

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

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

238162
### Run a Restore
239163

240164
```bash
241-
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./{{project_name}}/br/restore.sh $BKP_FOLDER_NAME
165+
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./project/br/restore.sh $BKP_FOLDER_NAME
242166
```
243167

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

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

261185
## Recommended: Track your changes

docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.9'
2-
31
# Common Django template for GeoNode and Celery services below
42
x-common-django:
53
&default-common-django
@@ -8,7 +6,7 @@ x-common-django:
86
env_file:
97
- .env
108
volumes:
11-
# - './src:/usr/src/{{project_name}}'
9+
# - './src:/usr/src/project' # Uncomment for local development
1210
- statics:/mnt/volumes/statics
1311
- geoserver-data-dir:/geoserver_data/data
1412
- backup-restore:/backup_restore
@@ -35,8 +33,8 @@ services:
3533
retries: 2
3634
environment:
3735
- IS_CELERY=False
38-
entrypoint: ["/usr/src/{{project_name}}/entrypoint.sh"]
39-
command: "uwsgi --ini /usr/src/{{project_name}}/uwsgi.ini"
36+
entrypoint: ["/usr/src/project/entrypoint.sh"]
37+
command: "uwsgi --ini /usr/src/project/uwsgi.ini"
4038

4139
# Celery worker that executes celery tasks created by Django.
4240
celery:
@@ -47,7 +45,7 @@ services:
4745
condition: service_healthy
4846
environment:
4947
- IS_CELERY=True
50-
entrypoint: ["/usr/src/{{project_name}}/entrypoint.sh"]
48+
entrypoint: ["/usr/src/project/entrypoint.sh"]
5149
command: "celery-cmd"
5250

5351
# Nginx is serving django static and media files and proxies to django and geonode

src/entrypoint.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ invoke () {
99
then
1010
/usr/local/bin/invoke $@
1111
else
12-
/usr/local/bin/invoke $@ > /usr/src/{{project_name}}/invoke.log 2>&1
12+
/usr/local/bin/invoke $@ > /usr/src/project/invoke.log 2>&1
1313
fi
1414
echo "$@ tasks done"
1515
}
@@ -35,10 +35,6 @@ echo GEODATABASE_URL=$GEODATABASE_URL
3535
echo SITEURL=$SITEURL
3636
echo ALLOWED_HOSTS=$ALLOWED_HOSTS
3737
echo GEOSERVER_PUBLIC_LOCATION=$GEOSERVER_PUBLIC_LOCATION
38-
echo MONITORING_ENABLED=$MONITORING_ENABLED
39-
echo MONITORING_HOST_NAME=$MONITORING_HOST_NAME
40-
echo MONITORING_SERVICE_NAME=$MONITORING_SERVICE_NAME
41-
echo MONITORING_DATA_TTL=$MONITORING_DATA_TTL
4238

4339
# invoke waitfordbs
4440

@@ -54,7 +50,6 @@ else
5450

5551
if [ ${FORCE_REINIT} = "true" ] || [ ${FORCE_REINIT} = "True" ] || [ ! -e "/mnt/volumes/statics/geonode_init.lock" ]; then
5652
invoke fixtures
57-
invoke monitoringfixture
5853
invoke initialized
5954
invoke updateadmin
6055
fi
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,4 @@
1818
#
1919
#########################################################################
2020

21-
import os
22-
23-
__version__ = (4, 2, 0, "dev", 0)
24-
25-
26-
default_app_config = "{{ project_name }}.apps.AppConfig"
27-
28-
29-
def get_version():
30-
import {{ project_name }}.version
31-
32-
return {{ project_name }}.version.get_version(__version__)
21+
default_app_config = "geonode_project.apps.AppConfig"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def run_setup_hooks(*args, **kwargs):
3333

3434

3535
class AppConfig(BaseAppConfig):
36-
name = "{{ project_name }}"
37-
label = "{{ project_name }}"
36+
name = "geonode_project"
37+
label = "geonode_project"
3838

3939
def ready(self):
4040
super(AppConfig, self).ready()

0 commit comments

Comments
 (0)