From 4fc8200a5c546cfc1a0918a8ddc2e66e74c235dd Mon Sep 17 00:00:00 2001 From: m431m <mmeliani@neogeo.fr> Date: Thu, 28 Sep 2023 17:20:46 +0200 Subject: [PATCH] Bump to 1.0.0 --- .gitlab-ci.yml | 51 +++---- LICENSE | 201 -------------------------- README.md | 26 +--- docker-compose.yaml | 47 ------ docker/auth.py | 6 +- docker/docker-entrypoint.d/01_install | 17 ++- docker/routers.py | 1 - docker/settings.py | 71 ++++++--- docker/start-celery-beat.sh | 2 +- docker/start-celery-default.sh | 32 +++- docker/start-celery-funcall.sh | 35 ++++- docker/start.sh | 19 ++- env | 96 ------------ requirements.txt | 2 +- 14 files changed, 154 insertions(+), 452 deletions(-) delete mode 100644 LICENSE delete mode 100644 docker-compose.yaml delete mode 100644 env diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6d77633..f7385b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,36 +1,25 @@ --- - stages: - - build - -build geofit docker image: - stage: build - only: - - geofit - when: manual - tags: - build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_SECRET\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination neogeo/onegeo-suite:geofit build tagged docker image: - stage: build - only: - - geofit - when: manual - tags: - - build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_SECRET\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination neogeo/onegeo-suite:geofit-$CI_PIPELINE_ID - - echo Image docker neogeo/onegeo-suite:geofit-$CI_PIPELINE_ID livrée - + stage: build + only: + - main + when: manual + tags: + - build + image: + name: 'gcr.io/kaniko-project/executor:debug' + entrypoint: + - '' + script: + - mkdir -p /kaniko/.docker + - >- + echo + "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_SECRET\"}}}" + > /kaniko/.docker/config.json + - >- + /kaniko/executor --context $CI_PROJECT_DIR --dockerfile + $CI_PROJECT_DIR/Dockerfile --destination + neogeo/onegeo-suite:1.0.0-build$CI_PIPELINE_ID diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8dada3e..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index e29da88..c2937ff 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,3 @@ -# Docker de OnegeoSuite +## Information -Ce dépot est utilisé pour générer les images docker de ONEGEO-SUITE. - -Les images sont générées automatiquement par la CI de Gitlab. - -## Test de l'image docker en local - -Le fichier `docker-compose.yaml` est fourni à titre d'exemple. - -Il peut être utilisé pour tester l'image en local. - -###### Commandes : - -* Lancer les docker - -```shell -docker-compose up -d -``` - -* Tout effacer (même la base de données) - -```shell -docker-compose down --volumes -``` +Ce dépot est utilisé pour générer l'image docker du site django onegeo-suite générique. diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index e2f5242..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,47 +0,0 @@ -version: '2.4' - -services: - onegeo-suite: &onegeo-suite - image: neogeo/onegeo-suite:testing - build: . - volumes: - - onegeo:/home/apprunner/onegeo_app/media - env_file: - - env - ports: - - 5000:80 - restart: always - mem_limit: 1g - mem_reservation: 512m - cpu_count: 1 - - onegeo-suite-worker: - <<: *onegeo-suite - command: src/docker/start-celery-default.sh - ports: [] - - onegeo-suite-worker-funcall: - <<: *onegeo-suite - command: src/docker/start-celery-funcall.sh - ports: [] - - onegeo-suite-beat: - <<: *onegeo-suite - command: src/docker/start-celery-beat.sh - ports: [] - - redis: - image: redis - - postgres: - image: postgis/postgis:12-3.1 - environment: - POSTGRES_PASSWORD: onegeo - POSTGRES_USER: onegeo - POSTGRES_DB: onegeo - volumes: - - postgres:/var/lib/postgresql/data - -volumes: - onegeo: - postgres: diff --git a/docker/auth.py b/docker/auth.py index dc047cf..981546f 100644 --- a/docker/auth.py +++ b/docker/auth.py @@ -2,7 +2,9 @@ from django.contrib.auth.models import Group from django.db import transaction from mozilla_django_oidc import auth + class OIDCAuthenticationBackend(auth.OIDCAuthenticationBackend): + def create_user(self, claims): user = super(OIDCAuthenticationBackend, self).create_user(claims) @@ -12,7 +14,7 @@ class OIDCAuthenticationBackend(auth.OIDCAuthenticationBackend): user.email = claims.get('email', '') user.status = 2 - #user.is_active = True + # user.is_active = True user.save() self.update_groups(user, claims) @@ -28,7 +30,7 @@ class OIDCAuthenticationBackend(auth.OIDCAuthenticationBackend): self.update_groups(user, claims) user.status = 2 - #user.is_active = True + # user.is_active = True return user def update_groups(self, user, claims): diff --git a/docker/docker-entrypoint.d/01_install b/docker/docker-entrypoint.d/01_install index f3a5f60..1df0f3d 100755 --- a/docker/docker-entrypoint.d/01_install +++ b/docker/docker-entrypoint.d/01_install @@ -1,5 +1,5 @@ #!/bin/bash -# --------------------------------------------------------------- # + create_link() { ln -s $1 $2 2> /dev/null @@ -10,8 +10,8 @@ create_link() exit 1 fi } -# --------------------------------------------------------------- # -echo "Step 01." + +echo "Starting Django projet" cd $APP_PATH/ marker_file="marker_file_step_01" if [ -f $marker_file ]; then @@ -26,23 +26,26 @@ else if [ -f "config/routers.py" ]; then rm config/routers.py fi + cp src/docker/routers.py config/routers.py + if [ -f "config/settings.py" ]; then rm config/settings.py fi + cp src/docker/settings.py config/settings.py + if [ -f "config/triggers.py" ]; then rm config/triggers.py fi + cp src/docker/triggers.py config/triggers.py + if [ -f "config/urls.py" ]; then rm config/urls.py fi - cp src/docker/routers.py config/routers.py - cp src/docker/settings.py config/settings.py - cp src/docker/triggers.py config/triggers.py cp src/docker/urls.py config/urls.py cp src/docker/auth.py config/auth.py # Wait for the postgres server - echo "Waiting for database..." + echo "Waiting for database" i=1 while true do diff --git a/docker/routers.py b/docker/routers.py index 574249b..b45c40b 100644 --- a/docker/routers.py +++ b/docker/routers.py @@ -20,7 +20,6 @@ class DefaultRouter(object): return DATABASE_FOR_WRITE def allow_relation(self, obj1, obj2, **hints): - # return obj1._state.db == obj2._state.db return True def allow_migrate(self, db, app_label, model_name=None, **hints): diff --git a/docker/settings.py b/docker/settings.py index 334c5b7..16e642a 100644 --- a/docker/settings.py +++ b/docker/settings.py @@ -7,6 +7,7 @@ Django settings for ONEGEO-SUITE project. from decouple import config import os from pathlib import Path +import re from django.utils.translation import gettext_lazy @@ -18,7 +19,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = config('SECRET_KEY', default='CHANGE_ME') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = config('DEBUG', default=True, cast=bool) +DEBUG = config('DEBUG', cast=bool, default=True) LOGGING = { 'version': 1, @@ -60,7 +61,6 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'prettyjson', 'django_reverse_admin', 'drfreverseproxy', 'nested_admin', @@ -88,7 +88,6 @@ INSTALLED_APPS = [ ] PASSWORD_HASHERS = [ - # 'onegeo_suite.contrib.onegeo_geoserv.hashers.GeoserverDigestEncryptor', 'django.contrib.auth.hashers.PBKDF2PasswordHasher', 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', 'django.contrib.auth.hashers.Argon2PasswordHasher', @@ -142,8 +141,8 @@ WSGI_APPLICATION = 'config.wsgi.application' DEFAULT_DB_ENGINE = 'django.contrib.gis.db.backends.postgis' DEFAULT_DB_HOST = config('DB_HOST', default='127.0.0.1') -DEFAULT_DB_PORT = config('DB_PORT', default='5432') -DEFAULT_DB_PORT_READONLY = config('DB_PORT_READONLY', default='5433') +DEFAULT_DB_PORT = config('DB_PORT', cast=int, default=5432) +DEFAULT_DB_PORT_READONLY = config('DB_PORT_READONLY', cast=int, default=5433) DEFAULT_DB_USER = config('DB_USER', default='postgres') DEFAULT_DB_PASSWORD = config('DB_PWD', default='postgres') DEFAULT_DB_NAME = config('DB_NAME', default='onegeo_suite') @@ -233,6 +232,7 @@ LOCALE_PATHS = [ f'{BASE_DIR}/src/django-onegeo-suite/onegeo_suite/contrib/onegeo_datapusher/conf/locale', f'{BASE_DIR}/src/django-onegeo-suite/onegeo_suite/contrib/onegeo_geospatial/conf/locale', f'{BASE_DIR}/src/django-onegeo-suite/onegeo_suite/contrib/onegeo_geoserv/conf/locale', + f'{BASE_DIR}/src/django-onegeo-suite/onegeo_suite/contrib/onegeo_geonet/conf/locale', f'{BASE_DIR}/src/django-onegeo-suite/onegeo_suite/contrib/onegeo_indexer/conf/locale', f'{BASE_DIR}/src/django-onegeo-suite/onegeo_suite/contrib/onegeo_maps/conf/locale', ] @@ -246,8 +246,9 @@ EMAIL_PORT = config('EMAIL_PORT', cast=int, default=25) EMAIL_USE_TLS = config('EMAIL_USE_TLS', cast=bool, default=True) DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL', default='') -ONEGEOSUITE_EMAIL_SUBJECT_PREFIX = config('EMAIL_SUBJECT_PREFIX', default='ONEGEO-SUITE |') -ONEGEOSUITE_EMAIL_FOOTER = config('EMAIL_FOOTER', default=None) + +ONEGEOSUITE_EMAIL_SUBJECT_PREFIX = config('EMAIL_SUBJECT_PREFIX', cast=str, default='ONEGEO-SUITE |') +ONEGEOSUITE_EMAIL_FOOTER = config('EMAIL_FOOTER', cast=str, default=None) ONEGEOSUITE_SUPERUSER_EMAIL_NOTIFICATION = False # Static and media files @@ -265,15 +266,16 @@ ONEGEOSUITE_TRIGGERS = [ # Celery settings: REDIS_HOST = config('REDIS_HOST', default='127.0.0.1') -REDIS_PORT = config('REDIS_PORT', default=6379) -REDIS_BASE = config('REDIS_BASE', default=0) +REDIS_PORT = config('REDIS_PORT', cast=int, default=6379) +REDIS_BASE = config('REDIS_BASE', cast=int, default=0) ONEGEOSUITE_CELERY_BROKER_URL = f'redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_BASE}' -ONEGEOSUITE_CELERY_RESULT_BACKEND = f'redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_BASE}' +ONEGEOSUITE_CELERY_RESULT_BACKEND = None ONEGEOSUITE_CELERY_ACCEPT_CONTENT = ['pickle', ] ONEGEOSUITE_CELERY_TASK_PROTOCOL = 1 ONEGEOSUITE_CELERY_TASK_SERIALIZER = 'pickle' ONEGEOSUITE_CELERY_RESULT_SERIALIZER = 'pickle' +ONEGEOSUITE_CELERY_SEND_EVENTS = False ONEGEOSUITE_CELERY_TIMEZONE = TIME_ZONE ONEGEOSUITE_CELERY_BEAT_SCHEDULER = 'onegeo_suite.schedulers.DatabaseScheduler' @@ -307,8 +309,8 @@ ONEGEOSUITE_SITE_LOGOUT_URI = '/onegeo/admin/logout/' # onegeo-resource settings: ONEGEO_RESOURCE_FTP_HOST = config('FTP_HOST', default='127.0.0.1') -ONEGEO_RESOURCE_FTP_PORT = config('FTP_PORT', default=22) -ONEGEO_RESOURCE_FTP_SECURE = config('FTP_SECURE', default=True) +ONEGEO_RESOURCE_FTP_PORT = config('FTP_PORT', cast=int, default=22) +ONEGEO_RESOURCE_FTP_SECURE = config('FTP_SECURE', cast=bool, default=True) ONEGEO_RESOURCE_FTP_BASE_DIR = config('FTP_BASE_DIR', default='/groups') ONEGEO_RESOURCE_FTP_GROUP_PREFIX = config('FTP_GROUP_PREFIX', default='usergroup') ONEGEO_RESOURCE_FTP_DROP_DIR = config('FTP_DROP_DIR', default='drop_here') @@ -317,17 +319,39 @@ ONEGEO_RESOURCE_FTP_DROP_DIR = config('FTP_DROP_DIR', default='drop_here') ONEGEOSUITE_DATASTORES_DBASE = { 'default': { - 'ENGINE': 'onegeo_suite.contrib.onegeo_geospatial.db.backends.postgis', + 'ENGINE': config( + 'DATAPUSHER_DB_ENGINE', + default='onegeo_suite.contrib.onegeo_geospatial.db.backends.postgis', + ), 'HOST': config('DATAPUSHER_DB_HOST', default=DEFAULT_DB_HOST), - 'PORT': config('DATAPUSHER_DB_PORT', default=DEFAULT_DB_PORT), + 'PORT': config('DATAPUSHER_DB_PORT', cast=int, default=DEFAULT_DB_PORT), 'NAME': config('DATAPUSHER_DB_NAME', default=DEFAULT_DB_NAME), 'USER': config('DATAPUSHER_DB_USER', default=DEFAULT_DB_USER), 'PASSWORD': config('DATAPUSHER_DB_PWD', default=DEFAULT_DB_PASSWORD), }, } -ONEGEOSUITE_DATASTORES_PK_FIELD = 'gid' +for key, val in os.environ.items(): + matched = re.match(r'DATASTORE_(?P<idx>\d+)_DB_ALIAS', key) + if not matched: + continue + # else: + idx = matched['idx'] + DATASTORE_DB_ALIAS = val + if DATASTORE_DB_ALIAS is not None: + ONEGEOSUITE_DATASTORES_DBASE[DATASTORE_DB_ALIAS] = { + 'ENGINE': config( + 'DATASTORE_%s_DB_ENGINE' % idx, + default='onegeo_suite.contrib.onegeo_geospatial.db.backends.postgis', + ), + 'HOST': config('DATASTORE_%s_DB_HOST' % idx), + 'PORT': config('DATASTORE_%s_DB_PORT' % idx, cast=int), + 'NAME': config('DATASTORE_%s_DB_NAME' % idx), + 'USER': config('DATASTORE_%s_DB_USER' % idx), + 'PASSWORD': config('DATASTORE_%s_DB_PWD' % idx, default=None), + } +ONEGEOSUITE_DATASTORES_PK_FIELD = 'gid' # onegeo-geoserv settings: @@ -352,18 +376,19 @@ ONEGEOSUITE_INDEXER_ELASTIC_UPSTREAM = config('INDEXER_ELASTIC_UPSTREAM', defaul ONEGEOSUITE_INDEXER_ELASTIC_CONNECTION = [ { 'host': config('INDEXER_ELASTIC_HOST', default='127.0.0.1'), - 'port': int(config('INDEXER_ELASTIC_PORT', default='9200')), + 'port': config('INDEXER_ELASTIC_PORT', cast=int, default='9200'), 'url_prefix': config('INDEXER_ELASTIC_PREFIX', default='elastic'), - 'use_ssl': config('INDEXER_ELASTIC_SSL', default='0') == '1', - 'timeout': int(config('INDEXER_ELASTIC_TIMEOUT', default=120)), - 'retry_on_timeout': True, - 'max_retries': 4, + 'use_ssl': config('INDEXER_ELASTIC_SSL', cast=bool, default=True), + 'timeout': config('INDEXER_ELASTIC_TIMEOUT', cast=int, default=120), + 'retry_on_timeout': config('INDEXER_ELASTIC_RETRY_ON_TIMEOUT', cast=bool, default=True), + 'max_retries': config('INDEXER_ELASTIC_MAX_RETRIES', cast=int, default=4), }, ] -ONEGEOSUITE_INDEXER_ELASTIC_ALIAS_ANONYMOUS = 'public' + +ONEGEOSUITE_INDEXER_ELASTIC_ALIAS_ANONYMOUS = config('INDEXER_ELASTIC_ALIAS_PUBLIC', default='public') ONEGEOSUITE_INDEXER_ELASTIC_INDEX = config('INDEXER_ELASTIC_INDEX', default='portail_data') -ONEGEOSUITE_INDEXER_ELASTIC_REPLICAS = config('INDEXER_ELASTIC_REPLICAS', default='0') -ONEGEOSUITE_INDEXER_ELASTIC_SHARDS = config('INDEXER_ELASTIC_SHARDS', default='1') +ONEGEOSUITE_INDEXER_ELASTIC_REPLICAS = config('INDEXER_ELASTIC_REPLICAS', cast=str, default='0') +ONEGEOSUITE_INDEXER_ELASTIC_SHARDS = config('INDEXER_ELASTIC_SHARDS', cast=str, default='1') ONEGEOSUITE_INDEXER_EXPORT_DIR = Path(MEDIA_ROOT) / config('INDEXER_EXPORT_DIR', default='indexer_exports') # Pour ique Django remplisse request.scheme avec https ou http diff --git a/docker/start-celery-beat.sh b/docker/start-celery-beat.sh index 4f3c7db..81d2373 100755 --- a/docker/start-celery-beat.sh +++ b/docker/start-celery-beat.sh @@ -1,5 +1,5 @@ #!/bin/bash -echo "Step 01. starting celery" +echo "Starting celery beat" exec celery --app=onegeo_suite beat -l INFO diff --git a/docker/start-celery-default.sh b/docker/start-celery-default.sh index 19495e8..89efa97 100755 --- a/docker/start-celery-default.sh +++ b/docker/start-celery-default.sh @@ -1,11 +1,29 @@ #!/bin/bash -echo "Step 01. starting celery" +echo "Starting celery worker" -while : -do - echo "(Re)Starting Celery" - celery --app=onegeo_suite worker -Q default,tasks,command,scenario -l INFO - echo "Celery is dead, restarting" -done +# App +CELERY_APP="onegeo_suite" +CELERYD_QUEUE="tasks,command,scenario" +CANCEL_TASKS_BY_DEFAULT="True" +CELERYD_WORKER_COUNT=2 +CELERYD_AUTOSCALE="3,1" +CELERYD_MAX_MEMORY_PER_CHILD=1024000 +# Extra command-line arguments to the worker +CELERYD_OPTS="--time-limit=86400 --autoscale=${CELERYD_AUTOSCALE} --max-memory-per-child=${CELERYD_MAX_MEMORY_PER_CHILD} --queues=${CELERYD_QUEUE}" + +# - %n will be replaced with the first part of the nodename. +# - %I will be replaced with the current child process index +# and is important when using the prefork pool to avoid race conditions. +# CELERYD_PID_FILE="/var/log/celery/%n.pid" +CELERYD_LOG_FILE="/var/log/celery/%n%I.log" +CELERYD_LOG_LEVEL="INFO" + +# you may wish to add these options for Celery Beat +CELERYBEAT_PID_FILE="/var/log/celery/beat.pid" +CELERYBEAT_LOG_FILE="/var/log/celery/beat.log" + +DJANGO_SETTINGS_MODULE='config.settings' + +exec celery --app=${CELERY_APP} worker --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS} --without-gossip --without-mingle --without-heartbeat diff --git a/docker/start-celery-funcall.sh b/docker/start-celery-funcall.sh index 73df92c..4b89dbc 100755 --- a/docker/start-celery-funcall.sh +++ b/docker/start-celery-funcall.sh @@ -1,10 +1,29 @@ #!/bin/bash -echo "Step 01. starting celery" - -while : -do - echo "(Re)Starting Celery" - celery --app=onegeo_suite worker -Q funcall -l INFO - echo "Celery is dead, restarting" -done +echo "Starting celery worker" + +# App +CELERY_APP="onegeo_suite" +CELERYD_QUEUE="funcall" +CANCEL_TASKS_BY_DEFAULT="True" + +CELERYD_WORKER_COUNT=2 +CELERYD_AUTOSCALE="3,1" +CELERYD_MAX_MEMORY_PER_CHILD=1024000 +# Extra command-line arguments to the worker +CELERYD_OPTS="--time-limit=86400 --autoscale=${CELERYD_AUTOSCALE} --max-memory-per-child=${CELERYD_MAX_MEMORY_PER_CHILD} --queues=${CELERYD_QUEUE}" + +# - %n will be replaced with the first part of the nodename. +# - %I will be replaced with the current child process index +# and is important when using the prefork pool to avoid race conditions. +# CELERYD_PID_FILE="/var/log/celery/%n.pid" +CELERYD_LOG_FILE="/var/log/celery/%n%I.log" +CELERYD_LOG_LEVEL="INFO" + +# you may wish to add these options for Celery Beat +CELERYBEAT_PID_FILE="/var/log/celery/beat.pid" +CELERYBEAT_LOG_FILE="/var/log/celery/beat.log" + +DJANGO_SETTINGS_MODULE='config.settings' + +exec celery --app=${CELERY_APP} worker --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS} --without-gossip --without-mingle --without-heartbeat \ No newline at end of file diff --git a/docker/start.sh b/docker/start.sh index 9e58533..01cac66 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,9 +1,22 @@ #!/bin/bash -echo "Step 01. starting nginx" +echo "Starting nginx" /etc/init.d/nginx restart -echo "Step 02. starting gunicorn" +echo "Starting gunicorn" -gunicorn -w ${GUNICORN_MAX_WORKERS:-3} -b 0.0.0.0:5000 config.wsgi:application --timeout ${GUNICORN_TIMEOUT:-1800} --max-requests ${GUNICORN_MAX_REQUEST:-20} +gunicorn config.wsgi:application \ + -b 0.0.0.0:5000 \ + --name OneGeoSuite-core \ + --workers ${GUNICORN_MAX_WORKERS:-2} \ + --threads ${GUNICORN_MAX_THREADS:-1} \ + --timeout ${GUNICORN_TIMEOUT:-1800} \ + --max-requests ${GUNICORN_MAX_REQUEST:-2000} \ + --worker-connections ${GUNICORN_MAX_WORKER_CONNECTIONS:-1000} \ + --log-level=info \ +# --bind=unix:/run/gunicorn/gunicorn_onegeosuite_core.sock \ +# --pid=/run/gunicorn/gunicorn_onegeosuite_core.pid +# --user=www-data --group=www-data \ +# --capture-output \ +# --error-logfile /var/log/gunicorn/onegeosuite_core_errors.log \ diff --git a/env b/env deleted file mode 100644 index c5c18ad..0000000 --- a/env +++ /dev/null @@ -1,96 +0,0 @@ -# Sample .env - -C_FORCE_ROOT=1 - -DJANGO_SITE=config -DJANGO_SETTINGS_MODULE=${DJANGO_SITE}.settings - -# settings.py -# =========== - -SECRET_KEY= -DEBUG= -LOG_LEVEL= -ALLOWED_HOSTS= - -DB_HOST= -DB_PORT= -DB_PORT_READONLY= -DB_USER= -DB_PWD= -DB_NAME= -DATABASE_FOR_READ= -DATABASE_FOR_WRITE= - -EMAIL_BACKEND= -EMAIL_HOST= -EMAIL_PORT= -EMAIL_HOST_USER= -EMAIL_HOST_PASSWORD= -EMAIL_USE_TLS= -DEFAULT_FROM_EMAIL= -EMAIL_SUBJECT_PREFIX= -EMAIL_FOOTER= - -REDIS_HOST= -REDIS_PORT= -REDIS_BASE= - -PUBLIC_BASE_URL= - -FTP_HOST= -FTP_PORT= -FTP_SECURE= -FTP_BASE_DIR= -FTP_GROUP_PREFIX= -FTP_DROP_DIR= - -DATAPUSHER_DB_HOST= -DATAPUSHER_DB_PORT= -DATAPUSHER_DB_USER= -DATAPUSHER_DB_PWD= -DATAPUSHER_DB_NAME= -DATAPUSHER_DATA_WS_UPSTREAM= -DATAPUSHER_DATA_WS_EXTERNAL_URL= - -GEOSERVER_OWS_EXTERNAL_URL= -GEOSERVER_GWC_UPSTREAM= -GEOSERVER_OWS_UPSTREAM= -GEOSERVER_LOCATION= -GEOSERVER_USER= -GEOSERVER_PWD= -GEOSERVER_WMS_FORMAT_LIST= -GEOSERVER_WFS_FORMAT_LIST= -GEOSERVER_WCS_FORMAT_LIST= - -GEONETWORK_CATALOG_UUID= -GEONETWORK_EXTERNAL_URL= -GEONETWORK_SRV_BASE_URL= -GEONETWORK_USERNAME= -GEONETWORK_PASSWORD= - -INDEXER_ELASTIC_UPSTREAM= -INDEXER_ELASTIC_HOST= -INDEXER_ELASTIC_PORT= -INDEXER_ELASTIC_PREFIX= -INDEXER_ELASTIC_SSL= -INDEXER_ELASTIC_TIMEOUT= -INDEXER_ELASTIC_INDEX= -INDEXER_ELASTIC_REPLICAS= -INDEXER_ELASTIC_SHARDS= -INDEXER_EXPORT_DIR= - -PUBLIC_PORTAL_DATASET_PATTERN_URL= - -SSO= -OIDC_RP_CLIENT_ID= -OIDC_RP_CLIENT_SECRET= -OIDC_RP_SIGN_ALGO= -OIDC_OP_AUTHORIZATION_ENDPOINT= -OIDC_OP_JWKS_ENDPOINT= -OIDC_OP_TOKEN_ENDPOINT= -OIDC_OP_USER_ENDPOINT= - -LOGIN_REDIRECT_URL= -LOGIN_URL= -LOGOUT_URL= diff --git a/requirements.txt b/requirements.txt index d4c109f..abed24c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -e git+https://github.com/neogeo-technologies/OWSLib.git@0.28.1.neogeo1#egg=OWSLib --e git+https://docker-onegeo-suite:D7S9gajfakqgzRwsAxB4@git.neogeo.fr/onegeo-suite/apps/django-onegeo-suite.git@1.0.0rc3#egg=django_onegeo_suite +-e git+https://docker-onegeo-suite:D7S9gajfakqgzRwsAxB4@git.neogeo.fr/onegeo-suite/apps/django-onegeo-suite.git@1.0.0#egg=django_onegeo_suite -e git+https://docker-onegeo-suite:D7S9gajfakqgzRwsAxB4@git.neogeo.fr/onegeo-suite/apps/django-onegeo-rproxy-mapstore2.git@1.0.0b2#egg=django_onegeo_rproxy_mapstore2 -e git+https://github.com/danpoland/drf-reverse-proxy@master#egg=drf-reverse-proxy python-decouple -- GitLab