geonode-project
geonode-project copied to clipboard
IndexError: list index out of range
Trying to set up geonode on Docker. Django container is stuck on perpetual restart loop and returns below errors when I examine the logs using docker-compose logs -f django
django4project_geonode | GeoNode databases are up - executing command django4project_geonode | waitfordbs tasks done django4project_geonode | DOCKER_ENV=production django4project_geonode | migrations***** django4project_geonode | Traceback (most recent call last): django4project_geonode | File "/usr/src/project_geonode/manage.py", line 31, in
django4project_geonode | execute_from_command_line(sys.argv) django4project_geonode | File "/usr/local/lib/python3.10/site-packages/django/core/management/init.py", line 419, in execute_from_command_line django4project_geonode | utility.execute() django4project_geonode | File "/usr/local/lib/python3.10/site-packages/django/core/management/init.py", line 363, in execute django4project_geonode | settings.INSTALLED_APPS django4project_geonode | File "/usr/local/lib/python3.10/site-packages/django/conf/init.py", line 82, in getattr django4project_geonode | self._setup(name) django4project_geonode | File "/usr/local/lib/python3.10/site-packages/django/conf/init.py", line 69, in _setup django4project_geonode | self._wrapped = Settings(settings_module) django4project_geonode | File "/usr/local/lib/python3.10/site-packages/django/conf/init.py", line 170, in init django4project_geonode | mod = importlib.import_module(self.SETTINGS_MODULE) django4project_geonode | File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module django4project_geonode | return _bootstrap._gcd_import(name[level:], package, level) django4project_geonode | File " ", line 1050, in _gcd_import django4project_geonode | File " ", line 1027, in _find_and_load django4project_geonode | File " ", line 1006, in _find_and_load_unlocked django4project_geonode | File " ", line 688, in _load_unlocked django4project_geonode | File " ", line 883, in exec_module django4project_geonode | File " ", line 241, in _call_with_frames_removed django4project_geonode | File "/usr/src/project_geonode/project_geonode/settings.py", line 79, in django4project_geonode | TEMPLATES[0]['DIRS'].insert(0, os.path.join(LOCAL_ROOT, "templates")) django4project_geonode | IndexError: list index out of range
Here is the /usr/src/project_geonode/project_geonode/settings.py
file:
# Django settings for the GeoNode project.
import os
import ast
try:
from urllib.parse import urlparse, urlunparse
from urllib.request import urlopen, Request
except ImportError:
from urllib2 import urlopen, Request
from urlparse import urlparse, urlunparse
# Load more settings from a file called local_settings.py if it exists
try:
from project_geonode.local_settings import *
# from geonode.local_settings import *
except ImportError:
from project_geonode.settings import *
#
# General Django development settings
#
PROJECT_NAME = 'project_geonode'
SITEURL = os.getenv("SITEURL", 'https://143.198.129.220/')
# add trailing slash to site url. geoserver url will be relative to this
if not SITEURL.endswith('/'):
SITEURL = '{}/'.format(SITEURL)
SITENAME = os.getenv("SITENAME", 'project_geonode')
# Defines the directory that contains the settings file as the LOCAL_ROOT
# It is used for relative settings elsewhere.
# Defines the directory that contains the settings file as the LOCAL_ROOT
# It is used for relative settings elsewhere.
LOCAL_ROOT = os.path.abspath(os.path.dirname(__file__))
WSGI_APPLICATION = "{}.wsgi.application".format(PROJECT_NAME)
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = os.getenv('LANGUAGE_CODE', "en")
INSTALLED_APPS = [];
if PROJECT_NAME not in INSTALLED_APPS:
INSTALLED_APPS += (PROJECT_NAME,)
# Location of url mappings
ROOT_URLCONF = os.getenv('ROOT_URLCONF', '{}.urls'.format(PROJECT_NAME))
# Additional directories which hold static files
# - Give priority to local geonode-project ones
STATICFILES_DIRS = [];
STATICFILES_DIRS = [os.path.join(LOCAL_ROOT, "static"), ] + STATICFILES_DIRS
# Location of locale file
LOCALE_PATHS = ('locale',)
LOCALE_PATHS = (
os.path.join(LOCAL_ROOT, 'locale'),
) + LOCALE_PATHS
TEMPLATES = []
TEMPLATES[0]['DIRS'].insert(0, os.path.join(LOCAL_ROOT, "templates"))
loaders = TEMPLATES[0]['OPTIONS'].get('loaders') or ['django.template.loaders.filesystem.Loader','django.template.loaders.app_directories.Loader']
# loaders.insert(0, 'apptemplates.Loader')
TEMPLATES[0]['OPTIONS']['loaders'] = loaders
TEMPLATES[0].pop('APP_DIRS', None)
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d '
'%(thread)d %(message)s'
},
'simple': {
'format': '%(message)s',
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'console': {
'level': 'ERROR',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
}
},
"loggers": {
"django": {
"handlers": ["console"], "level": "ERROR", },
"geonode": {
"handlers": ["console"], "level": "INFO", },
"geoserver-restconfig.catalog": {
"handlers": ["console"], "level": "ERROR", },
"owslib": {
"handlers": ["console"], "level": "ERROR", },
"pycsw": {
"handlers": ["console"], "level": "ERROR", },
"celery": {
"handlers": ["console"], "level": "DEBUG", },
"mapstore2_adapter.plugins.serializers": {
"handlers": ["console"], "level": "DEBUG", },
"geonode_logstash.logstash": {
"handlers": ["console"], "level": "DEBUG", },
},
}
CENTRALIZED_DASHBOARD_ENABLED = ast.literal_eval(os.getenv('CENTRALIZED_DASHBOARD_ENABLED', 'False'))
if CENTRALIZED_DASHBOARD_ENABLED and USER_ANALYTICS_ENABLED and 'geonode_logstash' not in INSTALLED_APPS:
INSTALLED_APPS += ('geonode_logstash',)
CELERY_BEAT_SCHEDULE['dispatch_metrics'] = {
'task': 'geonode_logstash.tasks.dispatch_metrics',
'schedule': 3600.0,
}
LDAP_ENABLED = ast.literal_eval(os.getenv('LDAP_ENABLED', 'False'))
if LDAP_ENABLED and 'geonode_ldap' not in INSTALLED_APPS:
INSTALLED_APPS += ('geonode_ldap',)
# Add your specific LDAP configuration after this comment:
# https://docs.geonode.org/en/master/advanced/contrib/#configuration
Here is my docker-compose.yml
:
version: '3.9'
# Common Django template for GeoNode and Celery services below
x-common-django:
&default-common-django
image: ${COMPOSE_PROJECT_NAME}_django:4.0
restart: on-failure
env_file:
- .env
volumes:
#- './src:/usr/src/project_geonode'
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
- backup-restore:/backup_restore
- data:/data
- tmp:/tmp
depends_on:
db:
condition: service_healthy
geoserver:
condition: service_healthy
services:
# Our custom django application. It includes Geonode.
django:
<< : *default-common-django
build:
context: ./
dockerfile: Dockerfile
container_name: django4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8001/"
start_period: 60s
interval: 60s
timeout: 10s
retries: 10
environment:
- IS_CELERY=False
entrypoint: ["/usr/src/project_geonode/entrypoint.sh"]
command: "uwsgi --ini /usr/src/project_geonode/uwsgi.ini"
# Celery worker that executes celery tasks created by Django.
celery:
<< : *default-common-django
image: ${COMPOSE_PROJECT_NAME}_django:4.0
container_name: celery4${COMPOSE_PROJECT_NAME}
depends_on:
- django
environment:
"docker-compose.yml" 193L, 5489B 11,3 Top
version: '3.9'
# Common Django template for GeoNode and Celery services below
x-common-django:
&default-common-django
image: ${COMPOSE_PROJECT_NAME}_django:4.0
restart: on-failure
env_file:
- .env
volumes:
#- './src:/usr/src/project_geonode'
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
- backup-restore:/backup_restore
- data:/data
- tmp:/tmp
depends_on:
db:
condition: service_healthy
geoserver:
condition: service_healthy
services:
# Our custom django application. It includes Geonode.
django:
<< : *default-common-django
build:
context: ./
dockerfile: Dockerfile
container_name: django4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8001/"
start_period: 60s
interval: 60s
timeout: 10s
retries: 10
environment:
- IS_CELERY=False
entrypoint: ["/usr/src/project_geonode/entrypoint.sh"]
command: "uwsgi --ini /usr/src/project_geonode/uwsgi.ini"
# Celery worker that executes celery tasks created by Django.
celery:
<< : *default-common-django
image: ${COMPOSE_PROJECT_NAME}_django:4.0
container_name: celery4${COMPOSE_PROJECT_NAME}
depends_on:
- django
environment:
"docker-compose.yml" 193L, 5489B 1,1 Top
- django
environment:
- IS_CELERY=True
entrypoint: ["/usr/src/project_geonode/entrypoint.sh"]
command: "celery-cmd"
# Nginx is serving django static and media files and proxies to django and geonode
geonode:
image: geonode/nginx:4.0
build: ./docker/nginx/
container_name: nginx4${COMPOSE_PROJECT_NAME}
environment:
- HTTPS_HOST=${HTTPS_HOST}
- HTTP_HOST=${HTTP_HOST}
- HTTPS_PORT=${HTTPS_PORT}
- HTTP_PORT=${HTTP_PORT}
- LETSENCRYPT_MODE=${LETSENCRYPT_MODE}
- RESOLVER=127.0.0.11
ports:
- "${HTTP_PORT}:80"
- "${HTTPS_PORT}:443"
volumes:
- nginx-confd:/etc/nginx
- nginx-certificates:/geonode-certificates
- statics:/mnt/volumes/statics
restart: on-failure
# Gets and installs letsencrypt certificates
letsencrypt:
image: geonode/letsencrypt:4.0
build: ./docker/letsencrypt/
container_name: letsencrypt4${COMPOSE_PROJECT_NAME}
environment:
- HTTPS_HOST=${HTTPS_HOST}
- HTTP_HOST=${HTTP_HOST}
- ADMIN_EMAIL=${ADMIN_EMAIL}
- LETSENCRYPT_MODE=${LETSENCRYPT_MODE}
volumes:
- nginx-certificates:/geonode-certificates
restart: on-failure
# Geoserver backend
geoserver:
image: geonode/geoserver:2.23.0
build: ./docker/geoserver/
container_name: geoserver4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://127.0.0.1:8080/geoserver/ows"
start_period: 60s
interval: 60s
54,0-1 33%
start_period: 60s
interval: 60s
timeout: 10s
retries: 10
env_file:
- .env
ports:
- "8080:8080"
volumes:
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
- backup-restore:/backup_restore
- data:/data
- tmp:/tmp
restart: on-failure
depends_on:
db:
condition: service_healthy
data-dir-conf:
condition: service_healthy
data-dir-conf:
image: geonode/geoserver_data:2.23.0
container_name: gsconf4${COMPOSE_PROJECT_NAME}
entrypoint: sleep infinity
volumes:
- geoserver-data-dir:/geoserver_data/data
restart: on-failure
healthcheck:
test: "ls -A '/geoserver_data/data' | wc -l"
# PostGIS database.
db:
# use geonode official postgis 13 image
image: geonode/postgis:13
command: postgres -c "max_connections=${POSTGRESQL_MAX_CONNECTIONS}"
container_name: db4${COMPOSE_PROJECT_NAME}
env_file:
- .env
volumes:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
restart: on-failure
healthcheck:
test: "pg_isready -d postgres -U postgres"
# uncomment to enable remote connections to postgres
#ports:
# - "5432:5432"
# Vanilla RabbitMQ service. This is needed by celery
102,7 67%
volumes:
jenkins_data:
driver: local
statics:
name: ${COMPOSE_PROJECT_NAME}-statics
nginx-confd:
name: ${COMPOSE_PROJECT_NAME}-nginxconfd
nginx-certificates:
name: ${COMPOSE_PROJECT_NAME}-nginxcerts
geoserver-data-dir:
name: ${COMPOSE_PROJECT_NAME}-gsdatadir
dbdata:
name: ${COMPOSE_PROJECT_NAME}-dbdata
dbbackups:
name: ${COMPOSE_PROJECT_NAME}-dbbackups
backup-restore:
name: ${COMPOSE_PROJECT_NAME}-backup-restore
data:
name: ${COMPOSE_PROJECT_NAME}-data
tmp:
name: ${COMPOSE_PROJECT_NAME}-tmp
rabbitmq:
name: ${COMPOSE_PROJECT_NAME}-rabbitmq
you must inherit the geonode.settings
somewhere otherwise some variables won't be defined
@afabiani True, I've had to define variables in settings.py
e.g SITE_URL
, TEMPLATES
, LOCALE_PATHS
So how do I inherit geocode.settings
?
it all depends on how you write the settings
file you are currently using.
In your case
try:
from project_geonode.local_settings import *
# from geonode.local_settings import *
except ImportError:
from project_geonode.settings import *
you must include on both the project_geonode
settings.py
and local_settings.py
the follwing line:
from geonode.settings import *