Use a single database for development

This commit is contained in:
Gabriel Roldan 2025-07-14 15:47:02 -03:00
parent ff7ae93b53
commit 7261c14e83
No known key found for this signature in database
GPG Key ID: 697E8F9DF72128E1
17 changed files with 95 additions and 232 deletions

View File

@ -63,10 +63,10 @@ cd ../compose
#### Run tests from host machine (full functionality)
**Note:** This requires the geodatabase port to be exposed (port 5433). The acceptance composition now exposes this port automatically.
**Note:** This requires the geodatabase port to be exposed (port 6432). The acceptance composition now exposes this port automatically.
```shell
# Start GeoServer services (geodatabase port 5433 will be exposed)
# Start GeoServer services (geodatabase port 6432 will be exposed)
cd ../compose
./acceptance_datadir up -d # or ./acceptance_pgconfig up -d

View File

@ -3,16 +3,16 @@
# Default GeoServer URL
GEOSERVER_URL=${GEOSERVER_URL:-"http://localhost:9090/geoserver/cloud"}
# Default database connection for local testing (requires geodatabase port exposed on 5433)
# Default database connection for local testing (requires geodatabase port exposed on 6432)
PGHOST=${PGHOST:-"localhost"}
PGPORT=${PGPORT:-"5433"}
PGDATABASE=${PGDATABASE:-"geodata"}
PGUSER=${PGUSER:-"geodata"}
PGPASSWORD=${PGPASSWORD:-"geodata"}
PGPORT=${PGPORT:-"6432"}
PGDATABASE=${PGDATABASE:-"acceptance"}
PGUSER=${PGUSER:-"geoserver"}
PGPASSWORD=${PGPASSWORD:-"geoserver"}
PGSCHEMA=${PGSCHEMA:-"test1"}
# Note: This script runs tests from the host machine and requires the geodatabase
# port to be exposed (5433). Start services with: ./acceptance_datadir up -d
# port to be exposed (6432). Start services with: ./acceptance_datadir up -d
# Help function
show_help() {
@ -35,7 +35,7 @@ show_help() {
echo "Environment variables:"
echo " GEOSERVER_URL GeoServer URL (default: http://localhost:9090/geoserver/cloud)"
echo " PGHOST Database host (default: localhost)"
echo " PGPORT Database port (default: 5433)"
echo " PGPORT Database port (default: 6432)"
echo ""
echo "Examples:"
echo " $0 # Run all tests"

View File

@ -10,9 +10,9 @@ RESOURCE_DIR = Path(__file__).parent / "resources"
# Database connection - defaults for container, can be overridden for local testing
PGHOST = os.getenv("PGHOST", "geodatabase")
PGPORT = int(os.getenv("PGPORT", "5432"))
PGDATABASE = os.getenv("PGDATABASE", "geodata")
PGUSER = os.getenv("PGUSER", "geodata")
PGPASSWORD = os.getenv("PGPASSWORD", "geodata")
PGDATABASE = os.getenv("PGDATABASE", "acceptance")
PGUSER = os.getenv("PGUSER", "geoserver")
PGPASSWORD = os.getenv("PGPASSWORD", "geoserver")
PGSCHEMA = os.getenv("PGSCHEMA", "test1")
WORKSPACE = "test_workspace"
DATASTORE = "test_datastore"

View File

@ -25,8 +25,3 @@ CONFIG_SERVER_DEFAULT_PROFILES=${LOGGING_PROFILE},native,standalone
JAVA_OPTS_DEFAULT=-XshowSettings:system -Dlogging.config=file:/etc/geoserver/logback-spring.xml -Xlog:cds
JAVA_OPTS_GEOSERVER=$JAVA_OPTS_DEFAULT
JDBCCONFIG_DBNAME=geoserver_config
JDBCCONFIG_URL=jdbc:postgresql://database:5432/${JDBCCONFIG_DBNAME}
JDBCCONFIG_USERNAME=geoserver
JDBCCONFIG_PASSWORD=geo5erver

View File

@ -1,7 +0,0 @@
services:
pgconfigdb:
deploy:
resources:
limits:
cpus: "1.0"
memory: 512M

View File

@ -1,36 +1,10 @@
services:
geodatabase:
image: imresamu/postgis:15-3.4
environment:
POSTGRES_DB: geodata
POSTGRES_USER: geodata
POSTGRES_PASSWORD: geodata
restart: always
volumes:
- ./acceptance_pg_entrypoint:/docker-entrypoint-initdb.d:ro
ports:
- "5433:5432" # Expose on port 5433 to avoid conflict with local PostgreSQL
healthcheck:
test: ["CMD-SHELL", "pg_isready -U geodata"]
interval: 30s
timeout: 10s
retries: 5
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M
acceptance:
image: geoservercloud/acceptance:latest
user: ${GS_USER}
depends_on:
geodatabase:
condition: service_healthy
postgis:
condition: service_healthy
gateway:
condition: service_healthy
discovery:
@ -68,7 +42,8 @@ services:
limits:
cpus: "1.0"
memory: 512M
postgis:
geodatabase:
shm_size: 128m
deploy:
resources:
limits:
@ -151,9 +126,3 @@ services:
limits:
cpus: "1.0"
memory: 512M
acldb:
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M

View File

@ -1,4 +0,0 @@
\c geodata
CREATE SCHEMA IF NOT EXISTS test1;
CREATE SCHEMA IF NOT EXISTS test2;
CREATE EXTENSION IF NOT EXISTS postgis;

View File

@ -8,6 +8,5 @@ COMPOSE_PROJECT_NAME=gscloud-acceptance-pgconfig \
docker compose \
-f compose.yml \
-f catalog-pgconfig.yml \
-f acceptance-pgconfig.yml \
-f acceptance.yml \
-f standalone.yml "$@"

View File

@ -8,7 +8,7 @@ x-volume-mounts: &geoserver_volumes
- datadir:/opt/app/data_directory
x-gs-dependencies: &gs-dependencies
database:
geodatabase:
condition: service_started
init-sample-data:
condition: service_completed_successfully
@ -19,9 +19,10 @@ x-gs-dependencies: &gs-dependencies
#
x-geoserver-env: &geoserver_environment
SPRING_PROFILES_ACTIVE: "${GEOSERVER_DEFAULT_PROFILES},jdbcconfig"
JDBCCONFIG_URL: "${JDBCCONFIG_URL}"
JDBCCONFIG_USERNAME: "${JDBCCONFIG_USERNAME}"
JDBCCONFIG_PASSWORD: "${JDBCCONFIG_PASSWORD}"
JDBCCONFIG_URL: "jdbc:postgresql://geodatabase:5432/geoserver?currentSchema=jdbcconfig"
JDBCCONFIG_SCHEMA: jdbcconfig
JDBCCONFIG_USERNAME: geoserver
JDBCCONFIG_PASSWORD: geoserver
services:
@ -33,24 +34,6 @@ services:
- datadir:/opt/app/data_directory
- ./catalog-datadir.tgz:/tmp/datadir.tgz
database:
extends:
file: templates.yml
service: postgrestemplate
environment:
POSTGRES_DB: "${JDBCCONFIG_DBNAME}"
POSTGRES_USER: "${JDBCCONFIG_USERNAME}"
POSTGRES_PASSWORD: "${JDBCCONFIG_PASSWORD}"
ports:
- 54321:5432
volumes:
- jdbcconfig_data:/var/lib/postgresql/data
deploy:
resources:
limits:
cpus: '2.0'
memory: 1G
wfs:
environment: *geoserver_environment
volumes: *geoserver_volumes

View File

@ -1,10 +1,7 @@
name: gscloud_dev_pgconfig
volumes:
pgconfigdb_data: # volume for postgresql data, used to store the geoserver config through pgconfig backend
x-gs-dependencies: &gs-dependencies
pgconfigdb:
geodatabase:
condition: service_started
required: true
@ -15,15 +12,6 @@ x-geoserver-env: &geoserver_environment
SPRING_PROFILES_ACTIVE: "${GEOSERVER_DEFAULT_PROFILES},pgconfig"
services:
pgconfigdb:
extends:
file: templates.yml
service: pgconfigdbtemplate
volumes:
- pgconfigdb_data:/var/lib/postgresql/data
ports:
- 8432:5432
wfs:
environment: *geoserver_environment
depends_on: *gs-dependencies

View File

@ -17,7 +17,7 @@ x-gs-dependencies: &gs-dependencies
acl:
condition: service_healthy
required: true
postgis:
geodatabase:
condition: service_started
required: true
init-test-data:
@ -38,12 +38,12 @@ services:
image: ${ACL_REPOSITORY}/geoserver-acl:${ACL_TAG}
environment:
# Override default values in the container's /etc/geoserver/acl-service.yml
- PG_HOST=acldb
- PG_HOST=geodatabase
- PG_PORT=5432
- PG_DB=acl
- PG_DB=geoserver
- PG_SCHEMA=acl
- PG_USERNAME=acl
- PG_PASSWORD=acls3cr3t
- PG_USERNAME=geoserver
- PG_PASSWORD=geoserver
- 'ACL_USERS_ADMIN_PASSWORD={noop}s3cr3t'
- 'ACL_USERS_GEOSERVER_PASSWORD={noop}s3cr3t'
- GEOSERVER_BUS_ENABLED=true
@ -54,7 +54,7 @@ services:
#- RABBITMQ_VHOST=""
#- SPRING_PROFILES_ACTIVE=logging_debug,logging_debug_events
depends_on:
acldb:
geodatabase:
condition: service_started
required: true
rabbitmq:

View File

@ -1,24 +1,34 @@
volumes:
#rabbitmq_data: # volume for rabbitmq data, so it doesn't create an anonymous one on each container
postgis_data:
acl_data:
geodatabase_data:
services:
postgis:
geodatabase:
extends:
file: templates.yml
service: postgistemplate
shm_size: 1g
environment:
POSTGRES_DB: geoserver
POSTGRES_USER: geoserver
POSTGRES_PASSWORD: geoserver
volumes:
- postgis_data:/var/lib/postgresql/data
- ./pg_entrypoint:/docker-entrypoint-initdb.d:ro
- geodatabase_data:/var/lib/postgresql/data
ports:
- 6432:5432
acldb:
extends:
file: templates.yml
service: acldbtemplate
volumes:
- acl_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U geoserver"]
interval: 30s
timeout: 10s
retries: 5
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: "2.0"
memory: 2g
rabbitmq:
image: rabbitmq:4-management-alpine
@ -44,22 +54,6 @@ services:
timeout: 30s
retries: 3
admin:
image: ${REPOSITORY}/geoserver-cloud-admin-server:${TAG}
user: ${GS_USER}
depends_on:
discovery:
condition: service_healthy
ports:
- 9091:8080
deploy:
mode: replicated
replicas: 0
resources:
limits:
cpus: '2.0'
memory: 512M
# Sample LDAP server to test LDAP Auth against
# Go to Authentication -> Authentication Providers -> Add new -> LDAP
# * Server URL: ldap://ldap:389/dc=georchestra,dc=org

View File

@ -0,0 +1,19 @@
\c geoserver
CREATE SCHEMA IF NOT EXISTS acl;
CREATE SCHEMA IF NOT EXISTS pgconfig;
CREATE SCHEMA IF NOT EXISTS jdbcconfig;
CREATE EXTENSION IF NOT EXISTS postgis;
-- works as "CREATE DATBASE IF NOT EXISTS"
SELECT 'CREATE DATABASE postgis' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'postgis')\gexec
\c postgis
CREATE EXTENSION IF NOT EXISTS postgis;
-- works as "CREATE DATBASE IF NOT EXISTS"
SELECT 'CREATE DATABASE acceptance' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'acceptance')\gexec
\c acceptance
CREATE SCHEMA IF NOT EXISTS test1;
CREATE SCHEMA IF NOT EXISTS test2;
CREATE EXTENSION IF NOT EXISTS postgis;

View File

@ -1,80 +1,46 @@
# for simplicity, use one pgbouncer instance per database
# postgis -> postgis_pg
# acldb -> acldb_pg
# pgconfigdb -> pgconfigdb_pg
# geodatabase -> geodatabase_pg
services:
postgis:
geodatabase:
extends:
file: templates.yml
service: pgbouncertemplate
environment:
PGBOUNCER_DATABASE: postgis
POSTGRESQL_HOST: postgis_pg
POSTGRESQL_DATABASE: postgis
POSTGRESQL_USERNAME: postgis
POSTGRESQL_PASSWORD: postgis
PGBOUNCER_DATABASE: geodatabase
POSTGRESQL_HOST: geodatabase_pg
POSTGRESQL_DATABASE: geoserver
POSTGRESQL_USERNAME: geoserver
POSTGRESQL_PASSWORD: geoserver
depends_on:
postgis_pg:
geodatabase_pg:
condition: service_started
ports:
- 6432:5432
acldb:
extends:
file: templates.yml
service: pgbouncertemplate
environment:
PGBOUNCER_DATABASE: acl
POSTGRESQL_HOST: acldb_pg
POSTGRESQL_DATABASE: acl
POSTGRESQL_USERNAME: acl
POSTGRESQL_PASSWORD: acls3cr3t
depends_on:
acldb_pg:
condition: service_started
ports:
- 7432:5432
pgconfigdb:
extends:
file: templates.yml
service: pgbouncertemplate
environment:
PGBOUNCER_DATABASE: pgconfig
POSTGRESQL_HOST: pgconfigdb_pg
POSTGRESQL_DATABASE: pgconfig
POSTGRESQL_USERNAME: pgconfig
POSTGRESQL_PASSWORD: pgconfig
depends_on:
pgconfigdb_pg:
condition: service_started
ports:
- 8432:5432
postgis_pg:
geodatabase_pg:
extends:
file: templates.yml
service: postgistemplate
shm_size: 1g
environment:
POSTGRES_DB: geoserver
POSTGRES_USER: geoserver
POSTGRES_PASSWORD: geoserver
volumes:
- postgis_data:/var/lib/postgresql/data
- ./pg_entrypoint:/docker-entrypoint-initdb.d:ro
- geodatabase_data:/var/lib/postgresql/data
ports:
- 6433:5432
acldb_pg:
extends:
file: templates.yml
service: acldbtemplate
volumes:
- acl_data:/var/lib/postgresql/data
ports:
- 7433:5432
pgconfigdb_pg:
extends:
file: templates.yml
service: pgconfigdbtemplate
volumes:
- pgconfigdb_data:/var/lib/postgresql/data
ports:
- 8433:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U geoserver"]
interval: 30s
timeout: 10s
retries: 5
deploy:
mode: replicated
replicas: 1
resources:
limits:
cpus: "2.0"
memory: 2g

View File

@ -27,17 +27,6 @@ services:
retries: 3
start_period: 5s
admin:
image: alpine:latest
entrypoint: ["sh", "-c", "echo 'Admin service is disabled in standalone mode' && tail -f /dev/null"]
restart: "no"
healthcheck:
test: ["CMD-SHELL", "exit 0"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
# Apply standalone profile to all services
gateway:
environment:

View File

@ -54,34 +54,6 @@ services:
POSTGRES_USER: postgis
POSTGRES_PASSWORD: postgis
POSTGIS_GDAL_ENABLED_DRIVERS: ENABLE_ALL
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgis"]
acldbtemplate:
extends:
service: postgistemplate
environment:
POSTGRES_DB: acl
POSTGRES_USER: acl
POSTGRES_PASSWORD: acls3cr3t
healthcheck:
test: ["CMD-SHELL", "pg_isready -U acl"]
pgconfigdbtemplate:
extends:
service: postgrestemplate
shm_size: 1g
environment:
POSTGRES_DB: pgconfig
POSTGRES_USER: pgconfig
POSTGRES_PASSWORD: pgconfig
healthcheck:
test: ["CMD-SHELL", "pg_isready -U pgconfig"]
deploy:
resources:
limits:
cpus: '4.0'
memory: 2G
pgbouncertemplate:
image: bitnami/pgbouncer:latest

2
config

@ -1 +1 @@
Subproject commit d3cae1cd55eae0249bd7e74121aec4f239eeca17
Subproject commit b8089b73e94341c90ea8da28e08461bbd7e762e6