Configuração de ambiente funcional com fluxo Postgresql -> geoserver -> geonode#14123
Configuração de ambiente funcional com fluxo Postgresql -> geoserver -> geonode#14123Gabriel-H2O-geo wants to merge 1 commit intoGeoNode:masterfrom
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Gabriel Leandro.
|
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Curl Username Password | 1d7b77c | SETUP_REFERENCE.txt | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
There was a problem hiding this comment.
Code Review
This pull request introduces a local deployment stack for GeoNode with support for an external PostGIS database, including Docker Compose configurations, initialization scripts, and automated layer synchronization via Celery Beat. The review feedback highlights several critical improvements: the need to include the .env_external file in the Docker environment configuration, the replacement of hardcoded datastore names with environment variables in both settings and status scripts, and the requirement for more robust JSON construction in the setup script to handle special characters in database passwords.
| image: geonode/geonode:local | ||
| restart: unless-stopped | ||
| env_file: | ||
| - .env |
There was a problem hiding this comment.
O arquivo .env_external não está incluído na configuração env_file do serviço Django/Celery. Como as variáveis de conexão ao banco externo (como EXT_DB_NAME ou GS_DATASTORE_NAME) são definidas nesse arquivo, elas não estarão disponíveis para a aplicação GeoNode em tempo de execução, o que fará com que a tarefa do Celery Beat falhe ao tentar localizar o datastore correto.
- .env
- .env_external| "schedule": int(os.environ.get("GEOSERVER_SYNC_INTERVAL", "120")), | ||
| "kwargs": { | ||
| "workspace": "geonode", | ||
| "store": "db_geo_prd", |
There was a problem hiding this comment.
O nome do datastore está fixo como "db_geo_prd". No entanto, o script setup_external_datastore.sh permite que o usuário customize este nome através das variáveis GS_DATASTORE_NAME ou EXT_DB_NAME. Se o usuário alterar essas configurações no arquivo .env_external, a sincronização automática de camadas falhará por não encontrar o datastore com o nome esperado.
| "store": "db_geo_prd", | |
| "store": os.environ.get("GS_DATASTORE_NAME", os.environ.get("EXT_DB_NAME", "db_geo_prd")), | |
| {\"@key\": \"database\", \"\$\": \"${DB_NAME}\"}, | ||
| {\"@key\": \"schema\", \"\$\": \"${DB_SCHEMA}\"}, | ||
| {\"@key\": \"user\", \"\$\": \"${DB_USER}\"}, | ||
| {\"@key\": \"passwd\", \"\$\": \"${DB_PASS}\"}, |
There was a problem hiding this comment.
A inserção direta da variável ${DB_PASS} dentro do payload JSON via string literal é vulnerável a erros de sintaxe. Se a senha do banco de dados contiver caracteres especiais, como aspas duplas ("), o JSON enviado ao GeoServer ficará malformado, resultando em erro na requisição. Recomenda-se o uso de uma ferramenta como jq para construir o JSON de forma segura ou garantir o escape manual dos caracteres.
| echo "[Datastore externo]" | ||
| DS=$(docker exec geoserver4geonode curl -s -o /dev/null -w "%{http_code}" \ | ||
| -u "admin:geoserver" \ | ||
| "http://localhost:8080/geoserver/rest/workspaces/geonode/datastores/db_geo_prd.json" 2>/dev/null) |
Ambiente Local GeoNode com Banco Externo
Fluxo de Dados
Arquitetura Docker
Arquivo:
docker-compose-local.yml— 9 serviçosAcesso ao banco externo: via
extra_hosts: host.docker.internal:host-gateway, permitindo que containers acessem hosts na rede do Docker host.Configuração de Credenciais
Nenhuma credencial é versionada. Arquivos sensíveis estão no
.gitignore:Banco Externo —
.env_externalTemplate disponível em
.env_external.sample:Registro do Datastore no GeoServer
Script:
setup_external_datastore.sh.env_external(ou variáveis de ambiente)bash setup_external_datastore.sh(após stack estar healthy)Sincronização Automática GeoServer → GeoNode
Arquivo:
geonode/settings.py—CELERY_BEAT_SCHEDULEComportamento:
GEOSERVER_SYNC_INTERVALno.env), o Celery Beat verifica novas tabelas no datastoredb_geo_prddo GeoServerskip_geonode_registered=Trueevita reprocessar camadas já sincronizadasexecute_signals=Truedispara geração de thumbnails e metadadosComo Subir o Ambiente
Ou usar o script automatizado:
bash start_local.shAcessos
Arquivos Adicionados/Modificados
docker-compose-local.ymlsetup_external_datastore.sh.env_external.samplestart_local.shstatus.shSETUP_REFERENCE.txt.gitattributes.gitignoregeonode/settings.pySegurança
.env*estão no.gitignoresetup_external_datastore.shlê credenciais de variáveis de ambiente /.env_externalALLOWED_HOSTS