Skip to content

Commit

Permalink
upgrade demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
giohappy committed Oct 25, 2023
1 parent 7d75afc commit ef23899
Show file tree
Hide file tree
Showing 67 changed files with 181 additions and 1,254 deletions.
33 changes: 22 additions & 11 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPOSE_PROJECT_NAME=geonode_master
COMPOSE_PROJECT_NAME=geonode_demo
# See https://github.com/containers/podman/issues/13889
# DOCKER_BUILDKIT=0
DOCKER_ENV=production
Expand All @@ -7,33 +7,40 @@ DOCKER_ENV=production
DOCKER_API_VERSION="1.24"
BACKUPS_VOLUME_DRIVER=local

GEONODE_BASE_IMAGE_VERSION=latest
NGINX_BASE_IMAGE_VERSION=latest
LETSENCRYPT_BASE_IMAGE_VERSION=latest
GEOSERVER_BASE_IMAGE_VERSION=latest
GEOSERVER_DATA_BASE_IMAGE_VERSION=latest
POSTGRES_BASE_IMAGE_VERSION=latest

C_FORCE_ROOT=1
FORCE_REINIT=false
INVOKE_LOG_STDOUT=true

# LANGUAGE_CODE=it-it
# LANGUAGES=(('en-us','English'),('it-it','Italiano'))

DJANGO_SETTINGS_MODULE=geonode_master.settings
DJANGO_SETTINGS_MODULE=geonode_demo.settings
GEONODE_INSTANCE_NAME=geonode

# #################
# backend
# #################
POSTGRES_USER=postgres
POSTGRES_PASSWORD={pgpwd}
GEONODE_DATABASE=geonode_master
GEONODE_DATABASE_USER=geonode_master
GEONODE_DATABASE=geonode_demo
GEONODE_DATABASE_USER=geonode_demo
GEONODE_DATABASE_PASSWORD={dbpwd}
GEONODE_GEODATABASE=geonode_master_data
GEONODE_GEODATABASE_USER=geonode_master_data
GEONODE_GEODATABASE=geonode_demo_data
GEONODE_GEODATABASE_USER=geonode_demo_data
GEONODE_GEODATABASE_PASSWORD={geodbpwd}
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
DATABASE_HOST=db
DATABASE_PORT=5432
DATABASE_URL=postgis://geonode_master:{dbpwd}@db:5432/geonode_master
GEODATABASE_URL=postgis://geonode_master_data:{geodbpwd}@db:5432/geonode_master_data
DATABASE_URL=postgis://geonode_demo:{dbpwd}@db:5432/geonode_demo
GEODATABASE_URL=postgis://geonode_demo_data:{geodbpwd}@db:5432/geonode_demo_data
GEONODE_DB_CONN_MAX_AGE=0
GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
Expand Down Expand Up @@ -177,9 +184,13 @@ CACHE_BUSTING_STATIC_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCATION=memcached:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
#
# Options for memcached binary, e.g. -vvv to log all requests and cache hits
#
MEMCACHED_OPTIONS=

MAX_DOCUMENT_SIZE=200
CLIENT_RESULTS_LIMIT=5
Expand Down Expand Up @@ -226,9 +237,9 @@ LDAP_GROUP_PROFILE_MEMBER_ATTR=uniqueMember

# expressed in KB
# CELERY__MAX_MEMORY_PER_CHILD="200000"
# ##
# ##
# Note right autoscale value must coincide with worker concurrency value
# CELERY__AUTOSCALE_VALUES="15,10"
# CELERY__AUTOSCALE_VALUES="15,10"
# CELERY__WORKER_CONCURRENCY="10"
# ##
# CELERY__OPTS="--without-gossip --without-mingle -Ofair -B -E"
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ local_settings.py

.idea/
.vscode/

.env
.vagrant/
Vagrantfile
/.env
23 changes: 15 additions & 8 deletions .override_dev_env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export SITEURL=http://localhost:8000/
export ALLOWED_HOSTS="['localhost',]"

export GEONODE_INSTANCE_NAME=geonode
export DJANGO_SETTINGS_MODULE=geonode_master.settings
export GEONODE_DATABASE=geonode_master
export DJANGO_SETTINGS_MODULE=geonode_demo.settings
export GEONODE_DATABASE=geonode_demo
export GEONODE_DATABASE_PASSWORD=geonode
export GEONODE_GEODATABASE=geonode_master_data
export GEONODE_GEODATABASE=geonode_demo_data
export GEONODE_GEODATABASE_PASSWORD=geonode

export DATABASE_URL=postgis://geonode_master:geonode@localhost:5432/geonode_master
export GEODATABASE_URL=postgis://geonode_master_data:geonode@localhost:5432/geonode_master_data
export DATABASE_URL=postgis://geonode_demo:geonode@localhost:5432/geonode_demo
export GEODATABASE_URL=postgis://geonode_demo_data:geonode@localhost:5432/geonode_demo_data
export DEFAULT_BACKEND_DATASTORE=datastore

export GEOSERVER_WEB_UI_LOCATION=http://localhost:8080/geoserver/
Expand Down Expand Up @@ -46,12 +46,17 @@ export DJANGO_EMAIL_USE_SSL=False
export DEFAULT_FROM_EMAIL="GeoNode <[email protected]>"

export LOCKDOWN_GEONODE=False
export CORS_ORIGIN_ALLOW_ALL=True
export X_FRAME_OPTIONS=SAMEORIGIN
export SESSION_EXPIRED_CONTROL_ENABLED=True
export DEFAULT_ANONYMOUS_VIEW_PERMISSION=True
export DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION=True

export CORS_ALLOW_ALL_ORIGINS=True
export GEOSERVER_CORS_ENABLED=True
export GEOSERVER_CORS_ALLOWED_ORIGINS=*
export GEOSERVER_CORS_ALLOWED_METHODS=GET,POST,PUT,DELETE,HEAD,OPTIONS
export GEOSERVER_CORS_ALLOWED_HEADERS=*

export ACCOUNT_OPEN_SIGNUP=True
export ACCOUNT_EMAIL_REQUIRED=True
export ACCOUNT_APPROVAL_REQUIRED=False
Expand All @@ -69,7 +74,6 @@ export API_LOCKDOWN=False
export TASTYPIE_APIKEY=

export CACHE_BUSTING_STATIC_ENABLED=False
export CACHE_BUSTING_MEDIA_ENABLED=False

export MAX_DOCUMENT_SIZE=2
export CLIENT_RESULTS_LIMIT=5
Expand All @@ -80,7 +84,7 @@ export MAPBOX_ACCESS_TOKEN=
export BING_API_KEY=
export GOOGLE_API_KEY=

export MONITORING_ENABLED=True
export MONITORING_ENABLED=False
export MONITORING_DATA_TTL=365
export USER_ANALYTICS_ENABLED=True
export USER_ANALYTICS_GZIP=True
Expand All @@ -94,3 +98,6 @@ export AVATAR_PROVIDERS='avatar.providers.PrimaryAvatarProvider','avatar.provide
export EXIF_ENABLED=True
export CREATE_LAYER=True
export FAVORITE_ENABLED=True

export DEFAULT_MAX_UPLOAD_SIZE=5368709120
export DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=5
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
FROM geonode/geonode-base:latest-ubuntu-22.04
LABEL GeoNode development team

RUN mkdir -p /usr/src/geonode_master
RUN mkdir -p /usr/src/geonode_demo

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

# add bower and grunt command
COPY src /usr/src/geonode_master/
WORKDIR /usr/src/geonode_master
COPY src /usr/src/geonode_demo/
WORKDIR /usr/src/geonode_demo

#COPY src/monitoring-cron /etc/cron.d/monitoring-cron
#RUN chmod 0644 /etc/cron.d/monitoring-cron
Expand All @@ -15,18 +22,18 @@ WORKDIR /usr/src/geonode_master

COPY src/wait-for-databases.sh /usr/bin/wait-for-databases
RUN chmod +x /usr/bin/wait-for-databases
RUN chmod +x /usr/src/geonode_master/tasks.py \
&& chmod +x /usr/src/geonode_master/entrypoint.sh
RUN chmod +x /usr/src/geonode_demo/tasks.py \
&& chmod +x /usr/src/geonode_demo/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

# # Install "geonode-contribs" apps
# Install "geonode-contribs" apps
# RUN cd /usr/src; git clone https://github.com/GeoNode/geonode-contribs.git -b master
# # Install logstash and centralized dashboard dependencies
# Install logstash and centralized dashboard dependencies
# RUN cd /usr/src/geonode-contribs/geonode-logstash; pip install --upgrade -e . \
# cd /usr/src/geonode-contribs/ldap; pip install --upgrade -e .

Expand All @@ -42,4 +49,4 @@ RUN apt-get autoremove --purge &&\
EXPOSE 8000

# We provide no command or entrypoint as this image can be used to serve the django project or run celery tasks
# ENTRYPOINT /usr/src/geonode_master/entrypoint.sh
# ENTRYPOINT /usr/src/geonode_demo/entrypoint.sh
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Geonode_Master
# Geonode_Demo

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

Expand All @@ -19,7 +19,7 @@ GeoNode template project. Generates a django project with GeoNode support.

```bash
python3.10 -m venv ~/.venvs/project_name
source ~/.venvs/geonode_master/bin/activate
source ~/.venvs/geonode_demo/bin/activate

pip install Django==3.2.*

Expand Down Expand Up @@ -67,7 +67,7 @@ Available at

## 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 ``geonode_master`` with whatever you would like to name your 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 ``geonode_demo`` with whatever you would like to name your project.*

To setup your project follow these instructions:

Expand All @@ -76,12 +76,12 @@ To setup your project follow these instructions:
```bash
git clone https://github.com/GeoNode/geonode-project.git -b <your_branch>
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
mkvirtualenv --python=/usr/bin/python3 geonode_master
mkvirtualenv --python=/usr/bin/python3 geonode_demo
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 geonode_master
django-admin startproject --template=./geonode-project -e py,sh,md,rst,json,yml,ini,env,sample,properties -n monitoring-cron -n Dockerfile geonode_demo

cd geonode_master
cd geonode_demo
```

2. Create the .env file
Expand Down Expand Up @@ -249,7 +249,7 @@ docker system prune -a
### Run a Backup

```bash
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_master/br/backup.sh $BKP_FOLDER_NAME
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_demo/br/backup.sh $BKP_FOLDER_NAME
```

- BKP_FOLDER_NAME:
Expand All @@ -266,13 +266,13 @@ SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_master/br/backup.sh $BKP
e.g.:

```bash
docker exec -it django4geonode_master sh -c 'SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_master/br/backup.sh $BKP_FOLDER_NAME'
docker exec -it django4geonode_demo sh -c 'SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_demo/br/backup.sh $BKP_FOLDER_NAME'
```

### Run a Restore

```bash
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_master/br/restore.sh $BKP_FOLDER_NAME
SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_demo/br/restore.sh $BKP_FOLDER_NAME
```

- BKP_FOLDER_NAME:
Expand All @@ -289,7 +289,7 @@ SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_master/br/restore.sh $BK
e.g.:

```bash
docker exec -it django4geonode_master sh -c 'SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_master/br/restore.sh $BKP_FOLDER_NAME'
docker exec -it django4geonode_demo sh -c 'SOURCE_URL=$SOURCE_URL TARGET_URL=$TARGET_URL ./geonode_demo/br/restore.sh $BKP_FOLDER_NAME'
```

## Recommended: Track your changes
Expand Down
2 changes: 1 addition & 1 deletion create-envfile.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _get_vals_to_replace(args):
prog="ENV file builder",
description="Tool for generate environment file automatically. The information can be passed or via CLI or via JSON file ( --file /path/env.json)",
usage="python create-envfile.py localhost -f /path/to/json/file.json",
allow_abbrev=False
allow_abbrev=False,
)
parser.add_argument(
"--noinput",
Expand Down
Empty file modified docker-build.sh
100755 → 100644
Empty file.
44 changes: 31 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ x-common-django:
env_file:
- .env
volumes:
# - './src:/usr/src/geonode_master'
# - './src:/usr/src/geonode_demo'
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
- backup-restore:/backup_restore
Expand All @@ -35,8 +35,8 @@ services:
retries: 2
environment:
- IS_CELERY=False
entrypoint: ["/usr/src/geonode_master/entrypoint.sh"]
command: "uwsgi --ini /usr/src/geonode_master/uwsgi.ini"
entrypoint: ["/usr/src/geonode_demo/entrypoint.sh"]
command: "uwsgi --ini /usr/src/geonode_demo/uwsgi.ini"

# Celery worker that executes celery tasks created by Django.
celery:
Expand All @@ -48,13 +48,16 @@ services:
condition: service_healthy
environment:
- IS_CELERY=True
entrypoint: ["/usr/src/geonode_master/entrypoint.sh"]
entrypoint: ["/usr/src/geonode_demo/entrypoint.sh"]
command: "celery-cmd"

# Nginx is serving django static and media files and proxies to django and geonode
geonode:
image: geonode/nginx:1.25.2
build: ./docker/nginx/
build:
context: ./docker/nginx
dockerfile: Dockerfile
args:
- BASE_IMAGE_VERSION=${NGINX_BASE_IMAGE_VERSION}
container_name: nginx4${COMPOSE_PROJECT_NAME}
env_file:
- .env
Expand All @@ -69,6 +72,7 @@ services:
- statics:/mnt/volumes/statics
restart: unless-stopped

# memcached service
memcached:
image: memcached:alpine
container_name: memcached4${COMPOSE_PROJECT_NAME}
Expand All @@ -83,8 +87,11 @@ services:

# Gets and installs letsencrypt certificates
letsencrypt:
image: geonode/letsencrypt:latest
build: ./docker/letsencrypt/
build:
context: ./docker/letsencrypt
dockerfile: Dockerfile
args:
- BASE_IMAGE_VERSION=${LETSENCRYPT_BASE_IMAGE_VERSION}
container_name: letsencrypt4${COMPOSE_PROJECT_NAME}
env_file:
- .env
Expand All @@ -94,8 +101,11 @@ services:

# Geoserver backend
geoserver:
image: geonode/geoserver:2.23.0
build: ./docker/geoserver/
build:
context: ./docker/geoserver
dockerfile: Dockerfile
args:
- BASE_IMAGE_VERSION=${GEOSERVER_BASE_IMAGE_VERSION}
container_name: geoserver4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl -m 10 --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://geoserver:8080/geoserver/ows"
Expand All @@ -121,7 +131,11 @@ services:
condition: service_healthy

data-dir-conf:
image: geonode/geoserver_data:2.23.0
build:
context: ./docker/geoserver_data
dockerfile: Dockerfile
args:
- BASE_IMAGE_VERSION=${GEOSERVER_DATA_BASE_IMAGE_VERSION}
container_name: gsconf4${COMPOSE_PROJECT_NAME}
entrypoint: sleep infinity
volumes:
Expand All @@ -132,8 +146,12 @@ services:

# PostGIS database.
db:
# use geonode official postgis 13 image
image: geonode/postgis:15
# use geonode official postgis 15 image
build:
context: ./docker/postgresql
dockerfile: Dockerfile
args:
- BASE_IMAGE_VERSION=${POSTGRES_BASE_IMAGE_VERSION}
command: postgres -c "max_connections=${POSTGRESQL_MAX_CONNECTIONS}"
container_name: db4${COMPOSE_PROJECT_NAME}
env_file:
Expand Down
Empty file modified docker-purge.sh
100755 → 100644
Empty file.
Loading

0 comments on commit ef23899

Please sign in to comment.