Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align to GeoNode master (4.2.0) and improve/fix docker initialization #457

Merged
merged 27 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d341641
- Align to GeoNode master (4.2.0)
afabiani Jul 27, 2023
9b42323
- Align to GeoNode master (4.2.0)
afabiani Jul 27, 2023
eb012d8
- Align to GeoNode master (4.2.0)
afabiani Jul 27, 2023
1e4d39a
- Align to GeoNode master (4.2.0)
afabiani Jul 27, 2023
4b0eb92
- Typo
afabiani Jul 28, 2023
5f00a32
- Code formatting
afabiani Jul 28, 2023
e6be49d
- Optimizing and fixing docker stack; removing unneeded/unused varia…
afabiani Jul 28, 2023
cba3e57
Update __init__.py
afabiani Jul 29, 2023
813c936
Typo on GEOSERVER_JAVA_OPTS
afabiani Jul 31, 2023
28ab6e2
Update docker-compose-test django healthcheck with retries
afabiani Jul 31, 2023
9e58413
drop PUBLIC_PORT and other unused Dockerfile env vars
giohappy Aug 21, 2023
f6185a8
disable abbreviated params
giohappy Aug 21, 2023
c0c4754
Removed legacy code
giohappy Aug 21, 2023
7494654
ported fixes to monitoring fixtures
giohappy Aug 21, 2023
39ccc52
Implement password configuration at init time
giohappy Aug 21, 2023
de4d1ac
Removed Azure vars from .env sample
giohappy Aug 21, 2023
04943eb
Add issing headers
giohappy Aug 21, 2023
a32750e
- Fix: the oauth2 "logoutUri" should match the public url too
afabiani Aug 21, 2023
a0c5b4b
- Fix: update the "geofence-datasource-ovr.properties.j2" in order t…
afabiani Aug 22, 2023
89bc888
set nginx image version
giohappy Aug 22, 2023
8c8f215
Fixes CodeQL
giohappy Aug 22, 2023
1034125
Improvements to create-envfile documentation
giohappy Aug 22, 2023
a5a780a
Cumulative improvements
giohappy Aug 22, 2023
3393da2
Give humane names to Geoserver variables
giohappy Aug 22, 2023
1a572c4
Use GEOSERVER_PUBLIC_LOCATION
giohappy Aug 22, 2023
634cb03
Remove geoserver_ui variable from .env.sample
giohappy Aug 22, 2023
55603ce
moved codeql-config to its folder to avoid trigger false workflow
giohappy Aug 22, 2023
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
4 changes: 4 additions & 0 deletions .codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
languages: ${{ matrix.language }}

paths-ignore:
- src/project_name/__init__.py
37 changes: 17 additions & 20 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
COMPOSE_PROJECT_NAME={{project_name}}
DOCKERHOST=
DOCKER_HOST_IP=
# See https://github.com/containers/podman/issues/13889
# DOCKER_BUILDKIT=0
DOCKER_ENV=production
Expand All @@ -13,7 +11,7 @@ C_FORCE_ROOT=1
FORCE_REINIT=false
INVOKE_LOG_STDOUT=true

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

DJANGO_SETTINGS_MODULE={{project_name}}.settings
Expand All @@ -25,8 +23,10 @@ GEONODE_INSTANCE_NAME=geonode
POSTGRES_USER=postgres
POSTGRES_PASSWORD={pgpwd}
GEONODE_DATABASE={{project_name}}
GEONODE_DATABASE_USER={{project_name}}
GEONODE_DATABASE_PASSWORD={dbpwd}
GEONODE_GEODATABASE={{project_name}}_data
GEONODE_GEODATABASE_USER={{project_name}}_data
GEONODE_GEODATABASE_PASSWORD={geodbpwd}
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
Expand All @@ -43,7 +43,7 @@ ASYNC_SIGNALS=True

SITEURL={siteurl}/

ALLOWED_HOSTS="['django', '*', '{hostname}']"
ALLOWED_HOSTS="['django', '{hostname}']"

# Data Uploader
DEFAULT_BACKEND_UPLOADER=geonode.importer
Expand All @@ -54,20 +54,13 @@ HAYSTACK_ENGINE_URL=http://elasticsearch:9200/
HAYSTACK_ENGINE_INDEX_NAME=haystack
HAYSTACK_SEARCH_RESULTS_PER_PAGE=200

# #################
# Jenkins
# CI/CD Server
# #################
JENKINS_HTTP_PORT=9080
JENKINS_HTTPS_PORT=9443

# #################
# nginx
# HTTPD Server
# #################
GEONODE_LB_HOST_IP={hostname}
GEONODE_LB_PORT=80
PUBLIC_PORT={public_port}
GEONODE_LB_HOST_IP=django
GEONODE_LB_PORT=8000
NGINX_BASE_URL={siteurl}

# IP or domain name and port where the server can be reached on HTTPS (leave HOST empty if you want to use HTTP only)
# port where the server can be reached on HTTPS
Expand All @@ -91,9 +84,11 @@ RESOLVER=127.0.0.11
# #################
# geoserver
# #################
GEOSERVER_WEB_UI_LOCATION={geoserver_ui}/geoserver/
GEOSERVER_PUBLIC_LOCATION={geoserver_ui}/geoserver/
GEOSERVER_LOCATION=http://geoserver:8080/geoserver/
GEOSERVER_LB_HOST_IP=geoserver
GEOSERVER_LB_PORT=8080
GEOSERVER_WEB_UI_LOCATION={siteurl}/geoserver/
GEOSERVER_PUBLIC_LOCATION={siteurl}/geoserver/
GEOSERVER_LOCATION=http://${GEOSERVER_LB_HOST_IP}:${GEOSERVER_LB_PORT}/geoserver/
GEOSERVER_ADMIN_USER=admin
GEOSERVER_ADMIN_PASSWORD={geoserverpwd}

Expand All @@ -106,7 +101,7 @@ OGC_REQUEST_POOL_CONNECTIONS=10
# Java Options & Memory
ENABLE_JSONP=true
outFormat=text/javascript
GEOSERVER_JAVA_OPTS=-Djava.awt.headless=true -Xms2G -Xmx4G -Dgwc.context.suffix=gwc -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/var/log/jvm.log -XX:PerfDataSamplingInterval=500 -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UseGCOverheadLimit -XX:+UseConcMarkSweepGC -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={geoserver_ui}/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={geoserver_ui}/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 @@ -152,6 +147,8 @@ ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_APPROVAL_REQUIRED=False
ACCOUNT_CONFIRM_EMAIL_ON_GET=False
ACCOUNT_EMAIL_VERIFICATION=none
ACCOUNT_EMAIL_CONFIRMATION_EMAIL=False
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED=False
ACCOUNT_AUTHENTICATION_METHOD=username_email
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_REGISTERED_MEMBERS_GROUP_NAME=True

Expand All @@ -170,7 +167,7 @@ TASTYPIE_APIKEY=
# #################
DEBUG={debug}

SECRET_KEY="{secret_key}"
SECRET_KEY='{secret_key}'

STATIC_ROOT=/mnt/volumes/statics/static/
MEDIA_ROOT=/mnt/volumes/statics/uploaded/
Expand All @@ -184,7 +181,7 @@ MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10

MAX_DOCUMENT_SIZE=2
MAX_DOCUMENT_SIZE=200
CLIENT_RESULTS_LIMIT=5
API_LIMIT_PER_PAGE=1000

Expand Down
72 changes: 0 additions & 72 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

31 changes: 12 additions & 19 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: "CodeQL"

on:
push:
branches: [ "master", "3.3.x", "4.x", "4.0.x" ]
branches: [ "master", 4.1.x ]
pull_request:
branches: [ "master" ]
branches: [ "master", 4.1.x ]
schedule:
- cron: "53 23 * * 3"
- cron: '38 4 * * 5'

jobs:
analyze:
Expand All @@ -20,23 +20,16 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ javascript, python ]
language: [ 'javascript', 'python' ]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
config-file: .codeql/codeql-config.yml

- name: Autobuild
uses: github/codeql-action/autobuild@v2
if: ${{ matrix.language == 'javascript' || matrix.language == 'python' }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 2 additions & 0 deletions .override_dev_env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export ACCOUNT_EMAIL_REQUIRED=True
export ACCOUNT_APPROVAL_REQUIRED=False
export ACCOUNT_CONFIRM_EMAIL_ON_GET=False
export ACCOUNT_EMAIL_VERIFICATION=none
export ACCOUNT_EMAIL_CONFIRMATION_EMAIL=False
export ACCOUNT_EMAIL_CONFIRMATION_REQUIRED=False
export ACCOUNT_AUTHENTICATION_METHOD=username_email

export OAUTH2_API_KEY=
Expand Down
57 changes: 11 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,17 @@
FROM ubuntu:22.04
FROM geonode/geonode-base:latest-ubuntu-22.10
LABEL GeoNode development team

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

## Enable postgresql-client-13
RUN apt-get update -y && apt-get install curl wget unzip gnupg2 -y
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
# will install python3.10
RUN apt-get install lsb-core -y
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list
# This section is borrowed from the official Django image but adds GDAL and others
RUN apt-get update -y && apt-get upgrade -y

# Prepraing dependencies
RUN apt-get install -y \
libgdal-dev libpq-dev libxml2-dev \
libxml2 libxslt1-dev zlib1g-dev libjpeg-dev \
libmemcached-dev libldap2-dev libsasl2-dev libffi-dev

RUN apt-get update -y && apt-get install -y --no-install-recommends \
gcc zip gettext geoip-bin cron \
postgresql-client-13 \
python3-all-dev python3-dev \
python3-gdal python3-psycopg2 python3-ldap \
python3-pip python3-pil python3-lxml \
uwsgi uwsgi-plugin-python3 python3-gdbm python-is-python3 gdal-bin

RUN apt-get install -y devscripts build-essential debhelper pkg-kde-tools sharutils
# RUN git clone https://salsa.debian.org/debian-gis-team/proj.git /tmp/proj
# RUN cd /tmp/proj && debuild -i -us -uc -b && dpkg -i ../*.deb

# Install pip packages
RUN pip install pip --upgrade \
&& pip install pygdal==$(gdal-config --version).* \
flower==0.9.4

# Activate "memcached"
RUN apt install -y memcached
RUN pip install pylibmc \
&& pip install sherlock

# add bower and grunt command
COPY src /usr/src/{{project_name}}/
WORKDIR /usr/src/{{project_name}}

COPY src/monitoring-cron /etc/cron.d/monitoring-cron
RUN chmod 0644 /etc/cron.d/monitoring-cron
RUN crontab /etc/cron.d/monitoring-cron
RUN touch /var/log/cron.log
RUN service cron start
#COPY src/monitoring-cron /etc/cron.d/monitoring-cron
#RUN chmod 0644 /etc/cron.d/monitoring-cron
#RUN crontab /etc/cron.d/monitoring-cron
#RUN touch /var/log/cron.log
#RUN service cron start

COPY src/wait-for-databases.sh /usr/bin/wait-for-databases
RUN chmod +x /usr/bin/wait-for-databases
Expand All @@ -67,11 +30,13 @@ RUN chmod +x /usr/bin/celery-cmd
# RUN cd /usr/src/geonode-contribs/geonode-logstash; pip install --upgrade -e . \
# cd /usr/src/geonode-contribs/ldap; pip install --upgrade -e .

RUN pip install --upgrade --no-cache-dir --src /usr/src -r requirements.txt
RUN pip install --upgrade -e .
RUN yes w | pip install --src /usr/src -Ur requirements.txt &&\
yes w | pip install --upgrade -e .

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

# Export ports
EXPOSE 8000
Expand Down
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ GeoNode template project. Generates a django project with GeoNode support.

## Table of Contents

- [Developer Workshop](#developer-Workshop)
- [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)
Expand All @@ -14,6 +15,48 @@ GeoNode template project. Generates a django project with GeoNode support.
- [Recommended: Track your changes](#recommended-track-your-changes)
- [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==3.2.*

mkdir ~/project_name
```

```bash
GN_VERSION=master

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

```bash
cd ~/project_name
python create-envfile.py
```
`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
Expand Down
Loading